/ Published in: PHP

Here is a working example on how to sort data in a grid.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php //basic mysql connection, you'd want to use a DB class or something $connect = @mysql_connect("localhost","username","password") or die("Could not connect to server."); $query = "SELECT * FROM table"; if ($check == 0) { echo "Table is empty."; } else { ?> <table> <?php $i = 1; if ($i == 1) { ?> <tr> <?php } ?> <td><?php echo $row['column']; ?></td> <?php if ($i == 7) { /* here we have 7 columns per row, if you want 10 columns just change this value to 10 instead of 7 */ $i = 0; ?> </tr> <?php } $i++; } ?> </tr> </table> <?php } ?>
Comments
