therelelogo Posted July 29, 2010 Share Posted July 29, 2010 Hi, having stopped php for a while, i'm a little rusty, can someone help me - instead of the results returning in a row by row format, can i have it so it returns column by column? so, rather than result 1 being first, then 2 underneath then 3 etc etc, can i have result 2 next to result 1? heres my code $result = mysql_query("SELECT * FROM members ORDER BY member_id DESC") or die(mysql_error()); echo "<table border='2'>"; echo "<tr> <th></th> <th></th> <th></th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row[printf('<img src="%s" height="96" width="128" style="border: 0" />', $row['profile_pic_short'])]; echo "</td><td>"; echo "<a href=\"PHP-Login/advert_pages/view_profile_specific.php?seller_name=$row[login]\">". $row['login'] . "</a>"; echo "</td></tr>"; } echo "</table>"; ?> all help appreciated thanks Quote Link to comment Share on other sites More sharing options...
therelelogo Posted July 29, 2010 Author Share Posted July 29, 2010 ...sorry to double post i also meant to say, the column is to break every 5 results. so first 5 on top line, 6-10 on second line, 11-15 on third etc thanks Quote Link to comment Share on other sites More sharing options...
therelelogo Posted August 4, 2010 Author Share Posted August 4, 2010 *BUMP* any suggestions appreciated, just need it to start a new line after 5 results? Quote Link to comment Share on other sites More sharing options...
AtlasC1 Posted August 4, 2010 Share Posted August 4, 2010 Would something like this be what you're after? $i = 0; echo "<tr>"; while($row = mysql_fetch_array( $result )) { if ($i % 5 == 0) echo "</tr><tr>"; // Print out the contents of each row into a table echo "<td>"; echo $row[printf('<img src="%s" height="96" width="128" style="border: 0" />', $row['profile_pic_short'])]; echo "</td><td>"; echo "<a href=\"PHP-Login/advert_pages/view_profile_specific.php?seller_name=$row[login]\">". $row['login'] . "</a>"; echo "</td>"; $i++ } echo "</tr>"; -jm Quote Link to comment Share on other sites More sharing options...
therelelogo Posted August 6, 2010 Author Share Posted August 6, 2010 hi, thanks for the reply few minor adjustments but that solved my problem thank you very much 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.