lakeshoretech Posted November 11, 2010 Share Posted November 11, 2010 I would like some advice from someone who already has the quick answer. User uses a form (drop down) to define a variable in their search of the db. PHP/MYSQL Choices are ALL, A, B, C. EXAMPLE1 They choose B. $variable = 'B' SELECT .... WHERE.... x table value = $variable (equals B) All works perfectly. EXAMPLE2 Now if they chose ALL (or don't chose), I have a problem. They choose nothing (which should be ALL records). I need it to go back to having no WHERE portion of the sql command, or a WHERE that pulls all records. They choose nothing. $ variable = 'ALL' SELECT ... WHERE... x table value = $variable (which now equals ALL) I thought % was a wildcard but doesn't work. This seems simple... but eludes me. What should I use for a variable value if there is NO selection or ALL selection???? The WHERE x table value = has to equal SOMETHING, right? Should I be using an IF THEN to zap the line if it equals "all"? Any advice would be helpful! Thanks! Link to comment https://forums.phpfreaks.com/topic/218352-wildcard-syntax/ Share on other sites More sharing options...
btherl Posted November 11, 2010 Share Posted November 11, 2010 WHERE column like '%' will fetch everything. The wildcards only work for "like", not for "=". Link to comment https://forums.phpfreaks.com/topic/218352-wildcard-syntax/#findComment-1132887 Share on other sites More sharing options...
lakeshoretech Posted November 11, 2010 Author Share Posted November 11, 2010 Awesome. Thank you. Link to comment https://forums.phpfreaks.com/topic/218352-wildcard-syntax/#findComment-1132889 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.