By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,650 Members | 1,823 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,650 IT Pros & Developers. It's quick & easy.

not sure where to start

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a

"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

P: n/a
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

P: n/a

"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

P: n/a
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

P: n/a

"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 discussion thread is closed

Replies have been disabled for this discussion.