Jump to content

[SOLVED] Find mysql row in an array?


christo16

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]; }
}			

 

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.