Jump to content

Recommended Posts

Hello all,

I would like to be able to match values from my mysql table to an array.  For example:

$result = mysql_query('SELECT * FROM db');
while ($row = mysql_fetch_array($result)) {
 if ($array == $row[id]){
 echo "We found your value"}
}

I realize this isn't a functional example, but basically I would like to match the id value with the same value in the array and if it doesn't exist go to the next row of the mysql.  I've tried a few things such as array_filter, with no success.  It seems like theres an easy way to do this that I don't know of.

Thank you for any help!

Link to comment
https://forums.phpfreaks.com/topic/64032-solved-find-mysql-row-in-an-array/
Share on other sites

You know what guys, I actually solved it.  I really should have played around with it more before posting here.  The array is just a bunch of integers.

What I did:

$result = mysql_query('SELECT * FROM db');
while ($row = mysql_fetch_array($result)) {
  if (in_array($row[id], $array)) {
   echo $row[id]; }
}			

 

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.