PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
You've got a for each loop inside of a while loop. $row is already an array, why are you assigning it to another array ($meals[])?
Forget the foreach loop and just use the while loop. But if you have more than one row, you should be using "fetch_array" which has both associate and numeric indexes.
JakeJ wrote:Forget the foreach loop and just use the while loop. But if you have more than one row, you should be using "fetch_array" which has both associate and numeric indexes.
I agree with the first part, but why would you want a numeric and associative if you are only using associative?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
But if you have more than one row, you should be using "fetch_array" which has both associate and numeric indexes.
It's my understanding that fetch_array without the second parameter will yield double results, also, and that fetch_assoc is the same as fetch_array with the MYSQL_ASSOC parameter.
Thanks for the help. I've been wrestling with this for a day & a half.