foreach and mysql_fetch_array problem

From: Date: Mon, 02 Jun 2003 21:25:05 +0000
Subject: foreach and mysql_fetch_array problem
Groups: php.general 
Request: Send a blank email to php-general+get-149842@lists.php.net to get a copy of this message
Hi all, I am trying to build up a table using values from a db as follows... mysql_select_db($db, $sql_connection); $result = mysql_query("SELECT * FROM $table WHERE $query LIMIT $limit",$sql_connection); $output = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"370\">\n"; foreach(mysql_fetch_array($result) as $key => $article){ //stuff } now if I use a while loop ie: while ($array = mysql_fetch_array($result)){ //stuff } all the matched rows are processed, however with the foreach model, $article isnt an array, it is the first row all merged together. Any ideas? ;o)

« previous php.general (#149842) next »