PHP While Loops from Arrays
- by Michael
I have a table that contains members names and a field with multiple ID numbers. I want to create a query that returns results where any values in the ID fields overlap with any values in the array.
For example: lastname: Smith
firstname: John
id: 101, 103
I have Array #1 with the values 101, 102, 103
I want the query to output all members who have the values 101 or 102 or 103 listed in their id field with multiple ids listed.
Array ( [0] => 101
[1] => 102
[2] => 103 )
$sql="SELECT firstname, lastname, id
FROM members WHERE id LIKE '%".$array_num_1."%'";
$result=mysql_query($sql);
while ($rows=mysql_fetch_array($result)) {
echo $rows['lastname'].', '.$rows['firstname'].'-'.$rows['id'];
}