Hi, I know how to list the contents of a mysql table, but could someone help me out with how I would lay it out like this: <table border="0"> <tr> <td>Text 01</td> <td>Text 02</td> <td>Text 03</td> <td>Text 04</td> </tr> <tr> <td>Text 05</td> <td>Text 06</td> <td>Text 07</td> <td>Text 08</td> </tr> <tr> <td>Text 09</td> <td>Text 10</td> <td>Text 11</td> <td>Text 12</td> </tr> <tr> <td>Text 13</td> <td>Text 14</td> <td>Text 15</td> <td>Text 16</td> </tr> </table> Code (markup): Cheers. Grant
Use a counter: $count = 1; //start the table echo '<table border="0"><tr>'; // run through the data while ($row=mysql_fetch_array($result)) { // if this is the fourth bit of data, add a new row if($count == 4) { echo '<td>' . $row['your_field_name'] . '</td></tr><tr>'; $count = 0; } // else just add a new cell else { echo '<td>' . $row['your_field_name'] . '</td>'; } $count++; } // after the data has run out, finish the table echo '</tr></table>'; PHP:
Thanks I will try that out in a sec. Could I ask how I would adapt this code to display a set amount of data (for example: 20) and have some kind of next button to go to the next 20. Basicly display 20 per page?
Add "LIMIT 0, 20" to the end of your query. Google "PHP Pagination" and you'll find lots of tutorials.