This is my code:
$query = mysql_query("SELECT * FROM books ORDER BY id") or die(mysql_error());
while($row = mysql_fetch_assoc($query)) {
echo $row["bookname"]." - ";
}
How to make only 5 books displayed in each line, by inserting a
at the start if the row is 5 or 10 or 15 etc...
Thanks
You could keep count of the times you've looped (increment a variable each time).
Compare the value modulus 5. If the result is 0 output the
$rowCounter = 1;
while($row = mysql_fetch_assoc($query)) {
echo $row["bookname"]." - ";
if( $rowCounter % 5 == 0 ) {
echo "<hr />";
}
$rowCounter++;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With