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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.