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. Quote Link to comment Share on other sites More sharing options...
play_ Posted November 10, 2007 Author Share Posted November 10, 2007 bumping Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
play_ Posted November 11, 2007 Author Share Posted November 11, 2007 Thanks poco. Quote Link to comment 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. Quote Link to comment 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>"; ?> Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.