I have a MySQL database and I use a while loop to take information from it. I also have an array that I want to loop though with foreach, but the problem is when I try to nest foreach in while there is no data in $strings. The $string variable works outside of the while loop, and there is nothing wrong with the database. What do I need to change so I can loop through both?
while ($field = mysql_fetch_assoc($query))
{
foreach($string as $strings)
{
//code here
}
}
Your for-loop is wrong. The array should come first.