Re: Not displaying all records

From: Date: Wed, 10 Apr 2002 16:20:37 +0000
Subject: Re: Not displaying all records
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-18400@lists.php.net to get a copy of this message
Thank you Jason that worked out great! Jennifer "Jason Wong" <phplist@gremlins.com.hk> wrote in message news:php.db-18399@news.php.net... > On Wednesday 10 April 2002 23:54, Jennifer Downey wrote: > > Hi all, > > > > I had to re-write this so it would at least show something on the page. > > > > $query = "SELECT id, name, image, quantity FROM > > {$config["prefix"]}_my_items WHERE uid={$session["uid"]} ORDER BY > > id"; > > $ret = mysql_query($query); > > $row = mysql_fetch_array($ret); > > Gets the first record > > > $id = $row['id']; > > $image = $row['image']; > > $name = $row['name']; > > $quantity = $row['quantity']; > > > > > > > > $display_block .="<img src=$image><br>$name<BR>$quantity"; > > echo "$display_block"; > > > > > > I know there are 2 records in the table but it will only display the first. > > What have I done wrong? > > You've only asked for the first row and that's what you got. > > Use a while loop to get all records: > > ... > $ret = mysql_query($query); > while ($row = mysql_fetch_array($ret)) { > do something or another; > } > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > > > /* > I'm all for computer dating, but I wouldn't want one to marry my sister. > */ --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.344 / Virus Database: 191 - Release Date: 4/2/2002

« previous php.db (#18400) next »