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!

passing a variable to a drop down list

Status
Not open for further replies.

josal

Programmer
Nov 28, 2003
2
AU
this is my screen

HS&E
Mathematics
English

THese are hyperlinks. These categories are retrieved from mysql. I want to be able to click on one of these links and perform a query that searches the database table for all titles that match the category clicked.

Please some help anybody.

many thanks, JOhn
 
you just add the field to the url
<a href=search.php?cat=hse>hs&e</a>

<a href=search.php?cat=mathematics>mathematics</a>
<a href=search.php?cat=english>english</a>

I don't know if you may use the & sign in the string since it also divides variables

in search.php you have the query
$query = &quot;select from tablename where categorie like '$cat'&quot;;

that's all


 
hos2 is right, but try rather this query:
Code:
$query = &quot;select from tablename where categorie 
like '%$cat%'&quot;;

The % (percentage) character represents any count of any characters so it will return a possitive search result even if you have e.g. &quot;dkjfasldmathematicsddfkjasdl&quot; in you database. If you don't write the % character in the search pattern, you won't get any possitive search result unless you have &quot;mathematics&quot; title in your database ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top