Hi guys, I am trying to do the age old thing of displaying data on my website. The exact problem is when i choose an event category form the event category table and hit go it displays the whole database. What I have noticed is in my events table where categoryID is a foregin key that its all set to zeros, not sure that this is what its supposed to be doing. My code is below.
any idea's anyone
Here is my first page
<?php
mysql_connect('localhost', 'phpuser', 'phpuser03')or die ("Database connection error");
mysql_select_db('booking');
//gets all the available events from the categories table.
$event_categories=mysql_query("SELECT * FROM event_categories ")
OR DIE("Unable to find events. Error: ".mysql_error());
print("<select name=\"categoryID\" size=1>\n");
print("<option value=\"b\">Select");
print("<option value=\"b\">-----");
while($row = mysql_fetch_array ($event_categories))
{
print("<option value=\"$row[categoryID]\">$row[category] \n");
}
print("</select>\n");
?>
my second page looks like this
<?php
$categoryID=$_GET['categoryID'];
$categoryID = addslashes($categoryID);
mysql_connect("localhost","phpuser","phpuser03") or die ("Database connection error");
mysql_select_db('booking');
$sql = "SELECT * FROM event WHERE categoryID='$categoryID'";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
print_r($row);
}
?>