473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

not sure where to start

I hope I can explain this right :) I'm new to php but am getting there
slowly.

I have a page with the letters ABCDE...etc
I want to be able to click on a letter and it will bring up a list of
title's to click on, so how do I get it to load a page if say A was
index.php?reviews=a

I've already got the page with the links in and that then loads the reviews
up if you click on the link, but I've made 26 pages areview, breview,
creview etc. I would just rather have a common page that would choose the
right one.

Is this a simple answer or is it going to be complex?

Thanks for any help :)
Jul 17 '05 #1
5 1664

"Hawk" <in**@hawk-web.co.uk> schreef in bericht
news:aZ***************@news-binary.blueyonder.co.uk...

I've already got the page with the links in and that then loads the reviews up if you click on the link, but I've made 26 pages areview, breview,
creview etc. I would just rather have a common page that would choose the
right one.

Is this a simple answer or is it going to be complex?


Perhaps this is helpful:

<?

// Get the file name
$file = strtoupper(basename(__FILE__));

// Generate the index
for ($i = 65; $i < 91; $i++) {
$c = chr($i);
if ($c == $file{0}) {
echo "$c\n";
} else {
echo "<a href=\"temp.php?reviews=$c\">$c</a>\n";
}
}

// Include the appropriate page
if (!isset($_GET['reviews'])) {
echo "including areview.php";
} else {
$rev = strtolower($_GET['reviews']);
// See if $rev is valid
if (ereg("^[a-z]$", $rev)) {
echo "including {$rev}review.php";
} else {
echo "Invalid value for \$review";
}
}

?>

HTH,
JW

Jul 17 '05 #2
Well, it depends on how you're storing the reviews. If they're just sitting
in a page, then I would just put some <div> tags around each section and
just flip them on and off using Javascript. There's no much point in using
PHP unless you have a more sophisticated backend.

Uzytkownik "Hawk" <in**@hawk-web.co.uk> napisal w wiadomosci
news:aZ***************@news-binary.blueyonder.co.uk...
I hope I can explain this right :) I'm new to php but am getting there
slowly.

I have a page with the letters ABCDE...etc
I want to be able to click on a letter and it will bring up a list of
title's to click on, so how do I get it to load a page if say A was
index.php?reviews=a

I've already got the page with the links in and that then loads the reviews up if you click on the link, but I've made 26 pages areview, breview,
creview etc. I would just rather have a common page that would choose the
right one.

Is this a simple answer or is it going to be complex?

Thanks for any help :)

Jul 17 '05 #3

"Hawk" <in**@hawk-web.co.uk> wrote in message
news:aZ***************@news-binary.blueyonder.co.uk...
I hope I can explain this right :) I'm new to php but am getting there
slowly.

I have a page with the letters ABCDE...etc
I want to be able to click on a letter and it will bring up a list of
title's to click on, so how do I get it to load a page if say A was
index.php?reviews=a

I've already got the page with the links in and that then loads the reviews up if you click on the link, but I've made 26 pages areview, breview,
creview etc. I would just rather have a common page that would choose the
right one.

Is this a simple answer or is it going to be complex?

Thanks for any help :)


On review.php I would just do something like this:
switch($_REQUEST["reviews"]) { //with the value you're passing
case "a":
include "a.php";
break;
case "b":
include "b.php";
break;
...and so on
}

This way a seperate file containing just the unique content for a, b, c,
etc. is pulled into the body of your page. If you want to do this all on one
big bad page you could use functions to call them like so

case "a":
acontent();
break;
etc.

//and elsewhere in the doc
function acontent() {
?>
//here's all my a stuff
<?
}

Hope that's what you were asking for.
Steve.
Jul 17 '05 #4
Thanks for your reply's guy I will give them a try, William asked me to post
me script, hope this helps?

<?
$category = "areview";
# setup SQL statement
$sql = " SELECT * FROM reviews ";
$sql .= " WHERE category = '$category' ";
# execute SQL statement
$rs = mysql_query($sql, $cid);
if (mysql_error()) { print "Database Error: $sql " . mysql_error(); }

# display results
while ($row = mysql_fetch_array($rs))
{
$siteurl = $row["siteurl"];
$sitename = $row["sitename"];
?><a onMouseover="return hidestatus()" href='<?php echo $siteurl; ?>'><?php
echo $sitename; ?></a><br/><?
}
?>
Jul 17 '05 #5

"Hawk" <in**@hawk-web.co.uk> wrote in message
news:4S*****************@news-binary.blueyonder.co.uk...
Thanks for your reply's guy I will give them a try, William asked me to post me script, hope this helps?

<?
$category = "areview";
# setup SQL statement
$sql = " SELECT * FROM reviews ";
$sql .= " WHERE category = '$category' ";
# execute SQL statement
$rs = mysql_query($sql, $cid);
if (mysql_error()) { print "Database Error: $sql " . mysql_error(); }

# display results
while ($row = mysql_fetch_array($rs))
{
$siteurl = $row["siteurl"];
$sitename = $row["sitename"];
?><a onMouseover="return hidestatus()" href='<?php echo $siteurl; ?>'><?php echo $sitename; ?></a><br/><?
}
?>


Since you are storing this information in a database, and I am assuming that
you have a field called title....
Why don't you just select a review (or a title) based on the starting
character ? One page would do it.

Just record that first letter being passed to your page and use it in a
query.
For a title starting with G :

$query = "select * from reviews where title like "G%";

Since both of these fields - category and title - are varchar, there
shouldn't be much of a difference in peformance.

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Henry Jordon | last post by:
hello I was wondering if someone could help me get a main going on this project I've completed the header file that the professor started us on but not really sure how to get the main going. If...
7
by: simondex | last post by:
Hi, Everyone! How could I make sure that nine values (from 0 to N) are all different without writing too many loops? I am not afraid of statistical parameters (e.g. coefficient of variation,...
7
by: Steven Bethard | last post by:
How do I make sure that my entire string was parsed when I call a pyparsing element's parseString method? Here's a dramatically simplified version of my problem: py> import pyparsing as pp py>...
3
by: Steve | last post by:
i pulled an example off the web and modified it somewhat and whats killimg me is that sometimes it works and sometimes it doesnt. the following is the only line that allows this thing to work over...
6
by: José Joye | last post by:
I have to compare 2 byte and I must be sure that they are fully identic. I have to perform this check about 1000 times per minute and on arrays that are between 100-200K in size. In that sense,...
6
by: Eric | last post by:
for example: SqlConnection is used in my project, how can I know if all connections were closed after open and execution. If some guys forget to close connections after using, how can i check it...
37
by: yogpjosh | last post by:
Hello All, I was asked a question in an interview.. Its related to dynamically allocated and deallocated memory. eg. //start char * p = new char; ...
6
by: divya | last post by:
I have a page name edit.asp which should expire immediately .The user cannot open this page directly he has to provide a password for entering this page.thus when the user enters edit.asp , it has...
0
by: 2Barter.net | last post by:
MAKE SURE TO CLICK 2 < < < 25 mar 2007 http://www.crawler.com/search/results.aspx?w=web&pts=1&tbid=60001&q=C... 21 mar 2007 Thank you Sincerely: Crawler For your barter for 2Barter...
5
by: sean.stonehart | last post by:
I've got a menu written in Javascript I'm wanting to enable but I need for it to sit in the center of a 3 column table. The menu keeps anchoring itself to the top left of the display, which is not...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.