Well I came up with an idea…not saying its a good one, but one none-the-less. Now I do know that this can easily be done by creating multiple pages that have the proper code I was wondering if it would be
possible to have a single php file that would be able to change on the fly by the press of a menu button.
For example:
MySQL database
Table = Books
Field1 = Title
Field2 = Genre
PHP file
Menu with two options: Fiction and Non-Fiction
When fiction is selected the page will display all rows from the database that has fiction in the genre field.
Then when non-fiction is selected the page will then display only the rows that have non-fiction in the genre field.
I know that the following sections in the file would need to change, just not sure how to make it work.
[code=php]<?php
include’config.php’;
mysql_connect(“$host”, “$username”, “$password”) or die(mysql_error());
mysql_select_db(“$db_name”) or die(mysql_error());
// Change the LIKE ‘% %’ when menu button is selected
$result = mysql_query(“SELECT * FROM books WHERE genre LIKE ‘%fiction or non-fiction%’ ORDER BY title ASC”);
?>
<html>
<head>
<!–Change when menu option is selected–>
<title>Fiction or Non-Fiction</title>
</head>
<!–Change when menu option is selected–>
<body id=”fiction or non-fiction”>
<div id=”menu”>
<!– Not sure how to make this work–>
<ul>
</li><a href=”????” target=”_parent”>Fiction</a></li>
</li><a href=”????” target=”_parent”>Non-Fiction</a></li>
</ul>
</div
<?php
while($row=mysql_fetch_array($result))
{
echo “”.$row[‘title’].””;
}
?>
</body>
</html>