play_ Posted November 10, 2007 Share Posted November 10, 2007 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: 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 More sharing options...
play_ Posted November 10, 2007 Author Share Posted November 10, 2007 bumping Link to comment https://forums.phpfreaks.com/topic/76764-solved-outputting-tabular-data/#findComment-388786 Share on other sites More sharing options...
pocobueno1388 Posted November 10, 2007 Share Posted November 10, 2007 Have you looked at this? http://www.phpfreaks.com/forums/index.php/topic,95426.0.html Link to comment https://forums.phpfreaks.com/topic/76764-solved-outputting-tabular-data/#findComment-388788 Share on other sites More sharing options...
play_ Posted November 11, 2007 Author Share Posted November 11, 2007 Thanks poco. Link to comment https://forums.phpfreaks.com/topic/76764-solved-outputting-tabular-data/#findComment-388849 Share on other sites More sharing options...
pocobueno1388 Posted November 11, 2007 Share Posted November 11, 2007 Don't forget to press "Topic Solved", that is if you had no trouble implementing the example into your script. Link to comment https://forums.phpfreaks.com/topic/76764-solved-outputting-tabular-data/#findComment-388854 Share on other sites More sharing options...
Crew-Portal Posted November 11, 2007 Share Posted November 11, 2007 <?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>"; ?> Link to comment https://forums.phpfreaks.com/topic/76764-solved-outputting-tabular-data/#findComment-388858 Share on other sites More sharing options...
Crew-Portal Posted November 11, 2007 Share Posted November 11, 2007 Oh wait Nvm I read the problem incorrectly! Link to comment https://forums.phpfreaks.com/topic/76764-solved-outputting-tabular-data/#findComment-388859 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.