desmondMorris Posted August 18, 2010 Share Posted August 18, 2010 hi, i am pulling data from a database, a picture and some text, i am able to have the records display vertically but i want them to display across the screen rather than downwards, but because of the page size, i only want 2 results per line. does any one know how i can do this? thanks in advance. Des This is the code i am currently using $result = mysql_query("select * from staff'"); echo "<table border='0' cellpadding='10' cellspacing='0'>"; echo "<tr>"; while($row = mysql_fetch_array($result)) { echo "<td><img src=../upload/".$row['Pic']." border='0' width='140' height='105' /></td>"; echo "<td>".$row['Name']."</br><b>".$row['Role']."</b></td>"; } echo "</tr>"; echo "</table>"; Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 18, 2010 Share Posted August 18, 2010 I think what you're after is Multi-column results. Quote Link to comment Share on other sites More sharing options...
sasa Posted August 18, 2010 Share Posted August 18, 2010 $result = mysql_query("select * from staff'"); $i=0: echo "<table border='0' cellpadding='10' cellspacing='0'>"; //echo "<tr>"; while($row = mysql_fetch_array($result)) { if($i == 0) echo '<tr>'; $i++; echo "<td><img src=../upload/".$row['Pic']." border='0' width='140' height='105' /></td>"; echo "<td>".$row['Name']."</br><b>".$row['Role']."</b></td>"; if($i==2){echo '</tr>'; $i=0;} } if($i>0)echo "<td> </td></tr>"; echo "</table>"; 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.