loop structure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've been experimenting some time now but i can't get it right.
I have a database in which I have a table with a list of photo_url

Table: photos
Id	photo_url
1	photos/boeket_s40.jpg
2	photos/boeket_k12.jpg
3	photos/boeket_z23.jpg
...


I get this out of the database with this query:
$sqlphoto="select * from photos where photo_type='$category'";
$exephoto=mysql_query($sqlphoto) or die (mysql_error());

Now I need a loop so that the photos are put into a table:

<table width="420" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->

        <tr>
          <td width="17" height="110"
valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
          <td width="120" valign="top">PICTURE HERE</td>
          <td width="13" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
          <td width="120" valign="top"> PICTURE HERE </td>
          <td width="13" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
          <td width="120" valign="top"> PICTURE HERE </td>
          <td width="13"><!--DWLayoutEmptyCell-->&nbsp;</td>
	    <td width="4"><!--DWLayoutEmptyCell-->&nbsp;</td>
        </tr>
        <tr>
          <td height="15"></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
      </table>

The first <tr> must be looped as long as there are photos in the array (so
something like #lines in array/3, with ceil())
In each <tr> there are 3 pictures in it's <td> tags:
 so maybe something like 
 for ($i=1;$i<3;$i++){
 <td width="120" valign="top">PICTURE HERE</td>
 <td width="13" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
 } 

I have tried several thing and I'm able to create the correct amount of rows
and the loop for the 3 cells in the row.
Unfortunately it always only shows the first picture from the array in each
of those cells.

Can someone help me out? THX

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux