Jump to content

php mysql query question


neddy

Recommended Posts

i have a table setup with the following in

id
game_id
name

now i want to filter/search the table for specific results so i did this

[code]SELECT * FROM my_table WHERE name LIKE %$name% ORDER BY id DESC[/code]

thats all well and good, i can use anything as $name and it returns all the rows with $name in name..

now i want to filter them more so i try

[code]SELECT * FROM my_table WHERE game_id = '1' OR game_id = '2' AND name LIKE %$name% ORDER BY id DESC[/code]

it gives me results where name is nothing like $name ?

any idea where im going wrong? or is there a better way to do what im trying to do?

if i havnt explained what im trying to do very well then please say so and ill try to explain a bit better [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /]

cheers

EDIT: forgot to say if i just do [code]SELECT * FROM my_table WHERE game_id = '1' AND name LIKE %$name% ORDER BY id DESC[/code]

it works

but i want to be able to search for multiple game_ids...
Link to comment
https://forums.phpfreaks.com/topic/11240-php-mysql-query-question/
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.