yobo Posted March 13, 2007 Share Posted March 13, 2007 hey all, i am not sure how i would do this, i have my index.php and i have created a dynmica menu and all the links and everything are stroed in the database here is the coding for index.php PHP Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> </body> </html> <?php include("config.php"); // connect to the mysql server $link = mysql_connect($server, $db_user, $db_pass) or die ("Could not connect to mysql because ".mysql_error()); // select the database mysql_select_db($database) or die ("Could not select database because ".mysql_error()); $count = 0; //This is used to avoid that "|" is printed before the first menu item $query = mysql_query("SELECT * FROM type ORDER BY name ASC") or die(mysql_error()); while ($row = mysql_fetch_object($query)) { if ($count!=0){echo " ";} echo "<a href=\"$row->link\" alt=\"$row->name\">".$row->name."<br>"; $count++; } ?> and in the database the links are formatted as this exmaple link name = admin hacks link address = cat.php?cat=admin now what i am trying to do is lets say the user clicks the admin hacks link i would like all hacks that are associated with that catagory pulled down how would i do that this is my cat.php coding PHP Code: <?php include("config.php"); // connect to the mysql server $link = mysql_connect($server, $db_user, $db_pass) or die ("Could not connect to mysql because ".mysql_error()); // select the database mysql_select_db($database) or die ("Could not select database because ".mysql_error()); $catname = "admin"; if (isset($_GET['index'])) {$catname = (get_magic_quotes_gpc()) ? $_GET['index'] : addslashes($_GET['index']);} $sql = "SELECT hacks.name, type.name ". "FROM hacks LEFT JOIN type ". "ON hacks.name = type.name"; $result = mysql_query($sql); Quote Link to comment https://forums.phpfreaks.com/topic/42558-how-to-perfrom-this-join-statment/ Share on other sites More sharing options...
artacus Posted March 13, 2007 Share Posted March 13, 2007 Yet another brilliantly asked vague question. I think what you are trying to ask is, "when a user selects an option from a list, I want a second option list to be populated based on what was selected in the first." If that's the question you just asked, then the answer is, "you do it with AJAX." If that's not the question you asked, then restate it. Quote Link to comment https://forums.phpfreaks.com/topic/42558-how-to-perfrom-this-join-statment/#findComment-206532 Share on other sites More sharing options...
yobo Posted March 13, 2007 Author Share Posted March 13, 2007 ok well what i am trying to do is lets say on my index.php i have a link thats says admin hacks and that link points to this page cat.php?cat=admin what i want to be able to do is when the user clicks that link i would like all hacks that are assicated with the admin hacks category to be pulled into the page at this moment in time i have 4 tables 1 to hold users another to hold the type of category which consists of 3 fileds that id column and the category name and the link column another table is where all the hacks are stored and the final one is called the hacktype which consists of hacksid and typeid so when the user submits a hack the name of the hack goes into the hacks table and then the id of that hack goes into the hacktype table along with the chossen category id (typeid) Quote Link to comment https://forums.phpfreaks.com/topic/42558-how-to-perfrom-this-join-statment/#findComment-206549 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.