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>"; Link to comment https://forums.phpfreaks.com/topic/211090-array-trouble/ 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. Link to comment https://forums.phpfreaks.com/topic/211090-array-trouble/#findComment-1100847 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>"; Link to comment https://forums.phpfreaks.com/topic/211090-array-trouble/#findComment-1100856 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.