Re: mysql php - while loops

From: Date: Thu, 28 Feb 2002 17:49:35 +0000
Subject: Re: mysql php - while loops
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-86632@lists.php.net to get a copy of this message
Keep track of rows, and add images at rows 4 & 8. See below Craig Westerman wrote: > The following lists 12 items from a fruits table. > > $results = mysql_query("SELECT ID, date, appleprice, orangeprice, pearprice > FROM fruits"); $x=1; > > while ($data = mysql_fetch_array($results)) > { > ?> > <p><?=$data["date"]?> - <?=$data["appleprice"]?> - > <?=$data["orangeprice"]?> - > <?=$data["pearprice"]?></p> $x++; if ($x==4) { // display first fruit images row } if ($x==8) { // display different fruit images } > > <? > } > > How would I modify the loop to display 4 items then a row of fruit images > then 4 more items then another row of different fruit images and then > finally finish the loop displaying the final 4 items? > > Thanks > > Craig ><> > westerman@chanuteks.com

« previous php.general (#86632) next »