peranha Posted February 7, 2008 Share Posted February 7, 2008 I want to display a result in a total of 3 columns. I have a sql database and here is the code that I use for it. // create query $query = "SELECT firstname, lastname, address, city, state, zip FROM testtable"; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($result) > 0) { // yes // print them one after another while($row = mysql_fetch_row($result)) { echo "<table>"; echo "<TR>"; echo "<TD>"; echo $row[0] . " " . $row[1] . "<BR>"; echo $row[2] . "<BR>"; echo $row[3] . ", " . $row[4] . " " . $row[5] . "<BR>"; echo "<BR>"; echo "</TD>"; echo "</tr>"; echo "</table>"; this puts the info in a single column, and I want to to span into 3 columns. example Record 1 Record 2 Record 3 Record 4 Record 5 Record 6 Quote Link to comment https://forums.phpfreaks.com/topic/89834-solved-display-in-multiple-columns/ Share on other sites More sharing options...
Zane Posted February 7, 2008 Share Posted February 7, 2008 begins a new row... starts a new column you start top to bottom, left to right NEW row NEW dimension NEW dimension contents: Record 1 NEW dimension NEW dimension contents: Record 2 all the while....keep tabs on whether the Record # is divisible by 3. if(($rec_id % 3)) == false if it's true you need a new row NEW row Quote Link to comment https://forums.phpfreaks.com/topic/89834-solved-display-in-multiple-columns/#findComment-460388 Share on other sites More sharing options...
peranha Posted February 7, 2008 Author Share Posted February 7, 2008 My code already creates a new row after each record is outputed. I need to know how to get mutiple TD's in a row. I have tried duplicating the TD part, and the screen displays nothing. That is what I need to know how to do. Quote Link to comment https://forums.phpfreaks.com/topic/89834-solved-display-in-multiple-columns/#findComment-460393 Share on other sites More sharing options...
pocobueno1388 Posted February 7, 2008 Share Posted February 7, 2008 Take a look at this topic http://www.phpfreaks.com/forums/index.php/topic,95426.0.html Quote Link to comment https://forums.phpfreaks.com/topic/89834-solved-display-in-multiple-columns/#findComment-460395 Share on other sites More sharing options...
peranha Posted February 7, 2008 Author Share Posted February 7, 2008 thanks, that worked great. Quote Link to comment https://forums.phpfreaks.com/topic/89834-solved-display-in-multiple-columns/#findComment-460405 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.