Jump to content

See if item in table has attribute in array


franzwarning

Recommended Posts

One way would be to select * and in the while loop use if(in_array($row[thesurname],$the_array_of_names)){do something;}

 

I use this method all the time. It is very efficient and does not take long at all, +1 imo.

 

No. Very no.

 

Stop being a negative nancy.

Link to comment
Share on other sites

Depends on the size of the array and where it's coming from. But in general you can

WHERE field IN ("value 1", "value 2", "value 3")

or

WHERE (field = "value1" OR field = "value 2" OR field = "value 3")

 

mm Double quotes work for string values in MySQL?  ;)

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.