RE: [PHP-DB] Getting One Row of a result

From: Date: Tue, 09 Oct 2001 11:02:49 +0000
Subject: RE: [PHP-DB] Getting One Row of a result
Groups: php.db 
Request: Send a blank email to php-db+get-13140@lists.php.net to get a copy of this message
if you know how to get the row then use mysql_fetch_row($result) ie, $sql = "SELECT name, address, whatever FROM people WHERE id = 473"; $result = mysql_query($sql); $row = mysql_fetch_row($result); $name = $row[0]; $address = $row[1]; $whatever = $row[3]; if you don't know how to get the one row you need you'll have to do some caomparisons within your while() loop Hope this helps Dave -----Original Message----- From: Jordan Elver [mailto:jord@theinternetone.co.uk] Sent: 09 October 2001 12:00 To: PHP DB Mailing List Subject: [PHP-DB] Getting One Row of a result Hi, If I know that a query is only going to return one record, what is the mmost efficient way of fetching that result and getting it into a variable? I currently use mysql_fetch_array with list, like: while(list($vars_here) = mysql_fetch_array($result)) { // do stuff } ANy help would be good, Thanks, Jord -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#13140) next »