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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple selects

Status
Not open for further replies.

brk1221

MIS
Joined
Jan 29, 2002
Messages
230
Location
US
Hi, I have an html form with 1 listbox. The "action=" points to a .php script. If a user chooses an option in the list box it will return the records with the selected criteria. I would like to add more listboxes to the form but I'm having trouble with the SELECT statement. The lone listbox is named "title" and the following is my select satement:

$sql = "SELECT * FROM contacts WHERE (title='$title')";

Any help would be appreciated

Thanks
 
Give the other select elements differing names. Use their values in your SQL query using the AND operator:

$sql = "SELECT * FROM contacts WHERE title='$title' AND someothercolumn = '$someotherelementname'";

Want the best answers? Ask the best questions: TANSTAAFL!
 
When doing that, I select options from either listbox and it returns 0 records.

$sql = "SELECT * FROM contacts WHERE title='$title' AND mla_no='$mla_no'";

In the database there is a record where the "title" is
VP SAFETY and "mla_no" is 115 when I plug in those selections I'm getting 0 records.

Thanks
 
Do the standard debugging.

Output your SQL query to the browser and examine it. Does it look as it should?

Copy and paste the query to your favorite MySQL management tool. What does the query return?

Want the best answers? Ask the best questions: TANSTAAFL!
 
How do I output the query to the browser?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top