Modulus will come in handy here, here's an example use :
 
 <table>
  <tr>
    <?php

    $result = mysql_query("SELECT foo FROM bar");

    $i = 0;
    while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
 
      echo "\t<td>". $row['foo'] ."</td>\n";
 
      if (($i++ % 5) === 4) {
        echo "</tr>\n<tr>\n";
      }
    }

    ?>
  </tr>
 </table>


Regards,
Philip Olson

On Wed, 19 Sep 2001, Kurth Bemis wrote:

> i'm trying to get a chunk of code to look 5 times then print 
> something..then look 5 time more....
> 
> I really want to loop 5 times (making 5 cells) then print </tr><tr>then 
> loop 5 more times for 5 cells...until the count is reached....like if i 
> have 22 things i want to have 4 rows of five and one row of two...get what 
> i'm trying to do?
> 
> heres the code that i have so far
> 
> <?php
>       while ($arraycnt <= (count ($typearray)-1)){
>               $type = $typearray[$arraycnt]; //grab a first chair in array
>               
>               $sqlquery = "SELECT * FROM chairs WHERE type = '$type'";  //construct 
>sql 
> query
>                       $result=mysql_query($sqlquery,$db);
>                       
>               while ($tempcnt <= 5){
>                       print "<tr bgcolor=\"#ffffff\">";
>                               while ($myrow = mysql_fetch_array($result)) {
>                                       print "<td align=\"center\"><img 
> src=\"/img/thumbs/".$myrow[modelnum]."_1.gif\" border=\"0\" 
> alt=\"\"><br>Model $myrow[modelnum]</td>";
>                               } //close cell loop
>                       $tempcnt++;
>                       print "</tr>";
>               } //close second while loop
>               $arraycnt++;
>       } //close first while loop
> ?>
> 
> look at http://www.strawhillchairs.com/cat/index.php
> 
> to see what i'm trying to do....
> 
> 
> -- 
> PHP General 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]
> 


-- 
PHP General 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]

Reply via email to