note 49770 deleted from function.msql-fetch-row by didou

From: Date: Mon, 04 Apr 2005 22:09:01 +0000
Subject: note 49770 deleted from function.msql-fetch-row by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-87462@lists.php.net to get a copy of this message
Note Submitter: und3rl1n3d at gmail dot com ---- $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 create 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. *Note that you need to use mysql_fetch_row, as many time as the number of the row's you have on your table. *The first mysql_fetch_row will create an array for the first row, the second mysql_fetch_row will create an array for the second row...

« previous php.notes (#87462) next »