Re: Database help

From: Date: Tue, 08 Oct 2002 22:18:03 +0000
Subject: Re: Database help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-119342@lists.php.net to get a copy of this message
In article <20021007225336.32084.qmail@pb1.pair.com>, dragonr@xmission.com says... > I am querying a database to populate a list. The list is suppose to start > with the first line of information in the database and continue untill have > been displayed. > > The problem I am having is the first line in the database is not being > displayed. The display starts on the second line. > > Here are the MySQL commands to retrieve the data... > > $fSelect = "SELECT lot,size,price FROM properties WHERE status = > 'Available' ORDER BY lot ASC"; > $fSql = mysql_query($fSelect, $db) or DIE("Unable to retrieve data"); > $useFields = mysql_fetch_array($fSql, MYSQL_ASSOC); The previous line gets the first record. Any further requests to the result set will get the second and subsequent records. > > The next line prints the lot field to the screen. The number printed to the > screen is the second lot number that matches this database query. > > Any suggestions on how to get the first information displayed to the screen? There is a perfectly good example in the docs for mysql_fetch_array - but to paraphrase it for your circumstance: $fSql = mysql_query($fSelect, $db) or DIE("Unable to retrieve data" . mysql_error() ); //Add debugging aid while($usefields = mysql_fetch_array($fSql, MYSQL_ASSOC) { extract($usefields); //Read the docs for extract() // do whatever here } Cheers -- David Robley Temporary Kiwi! Quod subigo farinam

« previous php.general (#119342) next »