RE: Dynamic <td> generation when retrieving data fromdatabase...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use while loops to cycle through & build the table, & mod to determine
if it's even or odd.
ie, If mod not = 0 then the number is odd.
I could only find fmod(), I don't know if this is the right function...

Gav


-----Original Message-----
From: Jonathan Villa [mailto:jvilla@isdesigndev.com] 
Sent: Friday, 23 May 2003 2:30 PM
To: Jadiel Flores
Cc: php-db@lists.php.net
Subject: Re:  Dynamic <td> generation when retrieving data
fromdatabase...


Actually, now that I think about it, I would also like to create the
<tr> dynamically.  

I'm looking for something which will determine if the result is 1 or an
odd or even number.

If it's 1, then just print out that result.

If it's an odd number > 3, display the results in rows of 3 colspaning
where needed.

If it's an even number, display the results in groups of 2, and colspan
where needed.

That is my logic, just need some syntax




On Thu, 2003-05-22 at 23:22, Jadiel Flores wrote:
> You can have an extra index in your loop, and every time you write a
<tr> 
> return it's value to 0, so, everytime you write a <td> ask 
> if($resultsindex+1 == count($results)) then you just have to check if
the 
> extra index is 0, 1 or 2, if it's 0 you should have a colspan=3 if
it's 1 
> use colspan=2 or if it is 2 you don't have write the colspan.
> 
> Hope I explained it ok.
> 
> At 11:10 p.m. 22/05/2003 -0500, you wrote:
> >Does anyone have a script which will do the following:
> >
> >For a shopping cart, I have the merchandise coming from the database
> >(image references, prices, ids, names, etc.)
> >
> >When I begin to display the results on the page I want to be able to
> >specify my <td> colspans and basic HTML table structure dynamically.
> >
> >For example, if result is 4, I want this
> >
> ><tr>
> >         <td>image1</td>
> >         <td>image2</td>
> >         <td>image3</td>
> ></tr>
> ><tr>
> >         <td colspan=3>image4</td>
> ></tr>
> >
> >if it's 5,
> ><tr>
> >         <td>image1</td>
> >         <td>image2</td>
> >         <td>image3</td>
> ></tr>
> ><tr>
> >         <td>image4</td>
> >         <td colspan=2>image5</td>
> ></tr>
> >
> >etc.
> >
> >Any idea, scripts?
> >
> >
> >
> >
> >
> >--
> >PHP Database Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> 



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux