Jump to content

PHP Query, which value to use to select all


Andreu

Recommended Posts

Hi,

 

I have done the following query:

 

$query = sprintf ("SELECT * FROM users WHERE country LIKE '$selCountry'");

$result = mysql_query($query,$link);

 

I want to obtain the users that are from a certain country but when $selCountry is equal to "All" I want to obtain all of them.

I have tried the query in mysql webpage using '%' and it works but when using this character from the php file it doesn't work.

 

Could someone help me?  :)

 

Thanks!!!

Hi, thanks for the quick reply  :)

 

The problem of this "if" is that it works fine if you have to do it just with one but if you have to do it with four, the code gets a bit heavy.

Is there any value to assign to the parameters equivalent to "*".

 

Code:

$query = sprintf ("SELECT * FROM tandem WHERE country LIKE '$selCountry' AND city LIKE '$selCity' AND lang1 LIKE '$iWantToSpeak' AND lang2 LIKE '$iSpeak'");

 

 

CHEERS :)

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.