Re: PHP + MySQL looping question

From: Date: Thu, 12 Dec 2002 21:45:47 +0000
Subject: Re: PHP + MySQL looping question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-128075@lists.php.net to get a copy of this message
On Friday 13 December 2002 05:40, Mark McCulligh wrote: > I was wondering if there is a easy way to loop through the same SQL results > many times. > I have a for loop that loops 3 time. Each time I want to loop through the > SQL result printing. > > The end result is printing the SQL results 3 times in a order. > > The problem is I have to reset the SQL result array on each for loop. How > do you do that? > > for ($i = 1; $i <= 3; $i++) { > while ($row = mysql_fetch_array($result)) { > //Some Code > echo $row['filed']; > } > //Reset $result - SQL result > } Read all the results into an array first, then you can print it out as many times as you like from the array. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* "I don't like spinach, and I'm glad I don't, because if I liked it I'd eat it, and I just hate it." -- Clarence Darrow */

« previous php.general (#128075) next »