Re: while loop and modulus?
| From: | Ron Wills | Date: | Tue, 27 Feb 2001 20:54:59 +0000 |
| Subject: | Re: while loop and modulus? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-41873@lists.php.net to get a copy of this message | ||
"James, Yz" wrote:
> OK, using this code:
>
> <?
>
> echo "<table border=\"0\">\n";
> echo "<tr>\n";
>
> $photocount = 0;
>
> while($row = mysql_fetch_array($result)) {
> $smallpic = $row['smallpic'];
>
> echo "<td>$smallpic</td>\n";
>
> if (($photocount % 3) == 2) {
> echo "</tr>\n<tr>\n";
> }
> $photocount++;
>
> }
>
This should fill in the remaining cells you need. You might have to tinker with
it a bit to fit your code though. Good luck :-)
for ($cnt = 0; $cnt < $phonecount % 3; $cnt++)
echo "<td> </td>
>
> echo "</tr>\n";
> echo "</table>";
>
> ?>
>
> And 8 photos in the table, I'm getting this output:
>
> <table border="0">
> <tr>
> <td>sm982438092.gif</td>
> <td>sm982437452.gif</td>
> <td>sm982439016.gif</td>
> </tr>
> <tr>
> <td>sm982529915.gif</td>
> <td>sm983222652.gif</td>
> <td>sm983222686.gif</td>
> </tr>
> <tr>
> <td>sm983222868.gif</td>
> <td>sm983222919.gif</td>
> </tr>
> </table>
>
> Great, except it's missing an end cell, and after a few hours fiddling about
> with code last night, I still didn't get any further in working out how I
> was going to echo a table cell even if data's missing. So, any help would
> be appreciated.
>
> Apologies for what're probably "easy" questions. I slog away at work all
> day, come back hoping to get something productive done on this, and the
> ol'brain won't take it. Frustrating, to say the least.
>
> James.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
209 Media <http://www.209media.com>
Ron Wills <ron@209media.com>
Programmer