By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

problem with returning all results from search query MYSQL & PHP

P: 12
here is my problem,
i have a website that compiles concert listings for users to search for shows in their local area, i ran into a problem with returning search results due to an improper format of my query, So i formatted the query properly Thanks to steve Klein :) , and all worked fine because there was only 1 show in my data base,
I tryed to search for the show and it returned properly, and then i searched for the show with a different date and it did not return, (thats what i wanted)
but now i populated the database with some more concert listings, and i searched for them using the proper date and location and now it will return no results for any of the other shows. (accept for the 1 show previously in my database).
any suggestions on why it will return this one show but when i search for another show with the exact data as the listing in the DB it will not return
here is how my database is set up.....

here are the columns in my table
id /PK, Auto Inc, Unsigned
State /Varchar
City /Varchar
Metro_Area /Varchar
Date_Input /Date
Band_or_Event_Name /Varchar
Genre /Varchar
Genre_1 /Varchar
Genre_2 /Varchar
Genre_3 /Varchar
Genre_4 /Varchar
Venue /Varchar
Other_info /Varchar
MP3_Link /Varchar
Link_to_Directions /Varchar
Age_Restrictions /Varchar

HERE IS MY QUERY

$query = "SELECT * FROM events WHERE
(((State LIKE '$State') AND
(City LIKE '$City%')) OR
(Metro_Area LIKE '$Metro_Area%')) AND
(Date_Input LIKE'$orderdate') AND
(Band_Or_Event_Name LIKE '$Band_or_Event_Name%') AND
(Genre LIKE '$Genre' OR Genre_2 LIKE '$Genre' OR Genre_3 LIKE '$Genre' OR Genre_4 LIKE '$Genre') AND
(Venue LIKE '$Venue%') AND
(Age_Restrictions LIKE '$Age_Restrictions%')
ORDER BY Date_Input, Band_or_Event_Name ASC";
May 5 '07 #1
Share this Question
Share on Google+
1 Reply


pbmods
Expert 5K+
P: 5,821
...now it will return no results for any of the other shows. (accept [sic] for the 1 show previously in my database).
Do all the events show up when you SELECT * FROM `events`?

Try unit-testing your query; start with `State` and make sure that works, then add `City`, etc. until you've rebuilt the query and it works.
May 5 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.