PHP MYSQL REPEATER WITH COUNTER

Hello, I need to arrange the results of a mysql query into divs which require 2 counters:

Assuming the results are 9 rows containing fields title, image content...

Select * FROM tblcontent ORDER BY Ordinal ASC...

While ($row =.....)
{


}...

I need a arrange the results into page and column divs as follows:

div=Page1
   div=column1... fields title, image content...
   div=column2... fields title, image content...
   div=column3... fields title, image content...
div=Page2
   div=column1... fields title, image content...
   div=column2... fields title, image content...
   div=column3... fields title, image content...
div=Page3
   div=column1... fields title, image content...
   div=column2... fields title, image content...
   div=column3... fields title, image content...

So basically counter 'column' runs 1-3 and loops back after 3, counter page increments after every counter column loop.

There will always be 1 page div and 1 column, but there maybe, 2 columns or in the case of 4 columns that would be 2 pages.

I'm new to php so appreciate as much detail as possible.
Thanks.
repeats after
onetoomanyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
assuming your result set has a field named 'id':
$i=0;
		$page=1;
		$groupCount=3;
		echo ("<div id='page".$page."'>")
		while( $row = mysql_fetch_assoc($result) )
		{

			
			echo("<div>".$row['id']."</div>");
			$i= (++$i % $groupCount);		
			if(!$i)
			{
				++$page;
				echo("</div><div id='page".$page."'>");
			}
		}

		echo("</div>");

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
onetoomanyAuthor Commented:
Thanks Hielo! Worked.

a couple of questions:

echo ("")

Has to be wrapped in parenthesis? Has to be in double quotes? Are there any other methods to write this?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.