on 6/26/01 10:43 AM, Matt Nigh at [EMAIL PROTECTED] wrote:
> I need a section of a record label site with a releases section listed
> horizontally but here's the twist: after every 4 releases, I want the
> releases to move to the next columns below.
>
> ex.
> release#1, release#2, release#3, release#4
> release#5, release#6
Basically you need to use the modulus operator.
Here's a rough example (untested):
<?php
// set number of rows
$n = 4;
// initialize cell count
$c = 0;
// start table code (omitted)
echo '<tr>';
// perform your query (omitted)
while ($row = mysql_fetch_array($query,$conn)) {
// make a new row if we reached the end of one
// but don't do it for the first row.
if ($c % $n == 0 && $c >= $n) {
echo '</tr><tr>';
}
echo '<td>';
// spit out all your mysql fields (omitted)
echo '</td>';
// increment your cellcounter;
$c++;
}
// make sure you don't have a malformed table
while ($c % $n != 0) {
echo '<td> </td>';
$c++;
}
echo '</tr>';
// end table code (omitted)
?>
Hope that helps.
Sincerely,
Paul Burney
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Paul Burney
Webmaster && Open Source Developer
UCLA -> GSE&IS -> ETU
(310) 825-8365
<[EMAIL PROTECTED]>
<http://www.gseis.ucla.edu/>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]