RE: [PHP] Re: Table formatting
| From: | César Aracena | Date: | Mon, 29 Jul 2002 03:27:08 +0000 |
| Subject: | RE: [PHP] Re: Table formatting | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-110082@lists.php.net to get a copy of this message | ||
I like this method a lot. Now, considering I do like FOR looping as a
fact, how can I make a loop inside another loop. I mean, if I tell the
first loop that $i=0 and then do the comparison and then add 1 to $i, in
the inner or second loop should I state that $i=$i or what? Also make it
$i=0???
Thanks, C.
> -----Original Message-----
> From: Chris Earle [mailto:chris@earleweb.com]
> Sent: Saturday, July 27, 2002 1:54 AM
> To: php-general@lists.php.net
> Subject: [PHP] Re: Table formatting
>
> You can do what he said or just put a separate loop inside the
original
> loop.
>
> Depending on how you get the info, you can use either way (his would
> create
> less overhead if you are just using the same <TD> info every row,
> otherwise
> they're really the same because his way you'll have to create an array
to
> access later for multiple rows, or just do my way and have the loop
access
> the NEXT *3* (or whatever) items ...).
>
> i.e.,
> for (LOOP FOR <TR>)
> {
> for (LOOP FOR <TD>) {}
> }
>
> "César aracena" <icaam@icaam.com.ar> wrote in message
> news:001a01c234f0$a5e8ad80$28ed0dd1@gateway...
> Hi all.
>
> Last nite I've came across a problem I wasn't able to figure out by my
> self. It's not difficult to make a loop that will make new *TABLE
ROWS*
> (<tr>) to show several DB objects in a nice way. what I need to do, is
> to display 2 or maybe even 3 of this objects stored in a DB per table
> row, separated in different *TABLE COLUMS* (<td>). how can I achieve
> this? What I usually do is:
>
> ------------------------------
> // DB QUERY
> $query = "SELECT * FROM table_name";
> $result = mysql_query($query) or die(mysql_error());
> $num_rows = mysql_num_rows($result);
>
> // NOW THE LOOP
> for ($i=0; $i<$num_rows; $i++)
> {
> $row = mysql_fetch_array($result);
> echo "<tr>";
> echo "<td>";
> echo $row[whatever];
> echo "</td>";
> echo "</tr>";
> }
> ------------------------------
>
> but how can I get 2 or 3 columns displaying different db objects? A
loop
> inside a loop?
>
> Thanks in advance,
>
> <mailto:webmaster@icaam.com.ar> Cesar Aracena
> CE / MCSE+I
> Neuquen, Argentina
> +54.299.6356688
> +54.299.4466621
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php