note 17601 added to function.mysql-fetch-array

From: Date: Sun, 16 Dec 2001 19:09:55 +0000
Subject: note 17601 added to function.mysql-fetch-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-22928@lists.php.net to get a copy of this message
Functions mysql_result and mysql_num_rows helps in situations when you need to cycle trough results several times (for example, in nested cycles). mysql_fetch_array in these situations works only for the first time. In example the external cycle is based on mysql_fetch_array (because every row is used only for one time), but internal cycle uses mysql_result and mysql_num_rows. while ($row = mysql_fetch_array($result_id_table1)) { $found = 0; for ($i=0, $n=mysql_num_rows($result_id_table2); $i<$n ; $i++) { $id2 = mysql_result($result_id_table2, $i, 0); if ($id2 == $row["id"]) { $found++; } } if ($found) { ... } } Ansis -- http://www.php.net/manual/en/function.mysql-fetch-array.php http://master.php.net/manage/user-notes.php?action=edit+17601 http://master.php.net/manage/user-notes.php?action=delete+17601 http://master.php.net/manage/user-notes.php?action=reject+17601

« previous php.notes (#22928) next »