Re: Odd - Even Results in a Table - Newbie question

From: Date: Fri, 11 May 2001 11:28:53 +0000
Subject: Re: Odd - Even Results in a Table - Newbie question
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-9248@lists.php.net to get a copy of this message
Hi, I think you could add the following portion of code inside your request in order to get two result arrays : odd[] and even[] ---------------------------------- $j = 0 ; $k = 0 ; for ($i=0;$i<rows;$i++) { $tmp = $i % 2 ; switch ($tmp) { case "0": even[$j] = row[$i] break; case "1": odd[$j] = row[$i] break; } } ---------------------------------- note : the "%" operator enables you to get the "rest" of a division operation. in your case, "$i % 2" enables you to determine whether "$i" is odd or even. regards, samuel Quoting "Rubanowicz, Lisa" <lisa.rubanowicz@cnh.com>: > HI all, > I am just a beginner at this stuff but I can't get my head around the > logic > of getting Row 1 in the left hand side of a two column table and Row 2 > data > in the right hand side. > Something like this > _______________________________________________________ > | Data from Row 1 in MySQL | Data from Row 2 in MySQL | > |__________________________|____________________________| > | Data from Row 3 in MySQL | Data from Row 4 in MySQL | > _______________________________________________________ > > Can someone please send me some help. I know I have to do something > with > 0,2,4,6,8 and 1,3,5,7,9 but how to lay it out within the HTML is just > a > puzzle. > I am sure it has been done before. Basically I want to use it on a > Table of > Contents page > > Thanks for any help > All the Best > Lisa > > Lisa Rubanowicz > Case ITC, > Navan, Ireland > Tel: #353 (0)46 77663 > > lisa.rubanowicz@cnh.com <mailto:lisa.rubanowicz@cnh.com> > > > -- Samuel Torton samuel@ncslab.com NCSLab.com

« previous php.db (#9248) next »