note 49768 added to function.msql-fetch-row

From: Date: Tue, 08 Feb 2005 10:16:03 +0000
Subject: note 49768 added to function.msql-fetch-row
Groups: php.notes 
Request: Send a blank email to php-notes+get-84655@lists.php.net to get a copy of this message
$conn = mysql_connect('localhost','root','qwerty'); $db = mysql_select_db('suporte', $conn); $val = mysql_query("SELECT * FROM ticket", $conn); $rows = mysql_num_rows($val); for ($a = 0;$a < $rows;$a++) { $row[$a] = mysql_fetch_row($val); } This will creat a number of var's equal to the number of row's you have in the table. To get the value you'll need to use: print_r ($row[0][0]); for example: if the first field on your table is: Login, and the first entry for this field is: uNd3rL1n3d print_r ($row[0][0]); will display: uNd3rL1n3d if the second entry for this field is: phpnet print_r ($row[1][0]); will display: phpnet to display the first entry of the second field use: print_r ($row[0][1]); It took me too much time to figure out how to do this, i hope i can help someone. ---- Manual Page -- http://www.php.net/manual/en/function.msql-fetch-row.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49768 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49768&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49768&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49768&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49768&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49768&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49768&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84655) next »