Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php & drop down lists

Status
Not open for further replies.

josal

Programmer
Nov 28, 2003
2
AU
hi all,

I have code that retrieves categories from a mysql database and then displays each category as a hyperlink one underneath the other.

What i want to be able to do is click on one of the hyperlinks and show all the titles in the database that correspond to the category that the hyperlink showed in a drop down menu.

I have the drop down menu under control, i think, but how do I tell it which titles to list from the click of a hyperlink?

any help would be great. many thanks,

John

 
When you create the hyperlink attach the category to it and use $_GET to access that cat to be used in the sql for the title retreival

ie
Code:
echo &quot;<a href=\&quot;search.php?cat=&quot;.$rows['category'].&quot;\&quot;>Click here for books about &quot;.$rows['category'].&quot;</a>&quot;;

then the link could look like

<a href=&quot;search.php?cat=action>Click here for books about action</a>
[code]
then in the search.php page

[code]
$cat=$_GET['cat'];

$sql=&quot;select titles from book_list_table where cat='$cat'&quot;;

$result=mysql_query($sql) or die (&quot;can't connect because &quot;.mysql_error());
...

hth

Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top