You can do what he said or just put a separate loop inside the original

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 ...).

for (LOOP FOR <TR>)
    for (LOOP FOR <TD>) {}

"CÚsar aracena" <[EMAIL PROTECTED]> wrote in message
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:

$query = "SELECT * FROM table_name";
$result = mysql_query($query) or die(mysql_error());
$num_rows = mysql_num_rows($result);

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:[EMAIL PROTECTED]> Cesar Aracena
Neuquen, Argentina

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to