note 38649 added to function.each
| From: | panania at 3ringwebs dot com | Date: | Wed, 31 Dec 2003 22:51:50 +0000 |
| Subject: | note 38649 added to function.each | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-62734@lists.php.net to get a copy of this message | ||
The last method for record sets is great if you don't know the number of rows returned from a
query, but if you do there's an easier way...
$strSQL = "SELECT * FROM table WHERE id=1";
$RecordsetSelect = $db->runQuery ($strSQL);
$row_Recordset1 = mysql_fetch_assoc($RecordsetSelect);
while (list($key, $val) = each($row_Recordset1)) {
echo "$key => $val\n";
}
mysql_free_result($RecordsetSelect);
Here we know that only 1 record will be returned because of the WHERE criteria. (Of course this is
dependent on you own DB schema.)
----
Manual Page -- http://www.php.net/manual/en/function.each.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38649
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38649&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38649&report=yes
Search -- http://master.php.net/manage/user-notes.php