Jump to content

wildcard syntax


lakeshoretech

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.