Jump to content

[SOLVED] Outputting tabular data


play_

Recommended Posts

Hi all

Here's the issue i'm having.

 

I know that when we output result from a table, and we use  <td>, we can insert a new row easily by using the modulus operator to inset a <tr>.

 

But what i'm trying to do is the contrary.

 

I have this:

$sql->query("select * from users");
echo "<table>";
while($sql->fetchArray()) {
echo "<tr>";
echo "<td>$row[0]</td>";
echo "<td>$row[1]</td>";
echo "<tr>";
}

echo "</table>";

 

So it outputs 12 results.

instead of having it listed in 12 rows, i'd like to display 6. and 6 next to it, and so on.

here's an image to better portray my problem:

p.jpg

 

The only thing i can think of is storing the mysql_fetch_array() results in an array,

and then output the array because if the fetch_array_result is stored in an arryay,

i can advance the pointer to the next td.

Link to comment
https://forums.phpfreaks.com/topic/76764-solved-outputting-tabular-data/
Share on other sites

<?php
echo "<table>";
$sql->query("select * from users");
$result = @mysql_query($sql,$connection) or die('Ouch!');
$num=mysql_num_rows($result);
while ($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>$row['0']</td>";
echo "<td>$row['1']</td>";
echo "<tr>";
}
echo "</table>";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.