hi mladams,
Did you read and understood my code snap it? Because if you do, change that in to your requirement would be really simple. My first advice for you is please read the code and understand it so next time if u encounter similar problem you dont have to ask anyone. 🙂
By the way i found one mistake in your query.
$sql = mysql_query("SELECT photo_id, photo_caption_1, photo_listing
FROM listing_photo
WHERE photo_listing = 136
ORDER BY `photo_status_main` <> 'main'
LIMIT 10");
what do you mean by ORDER BY photo_status_main <> 'main' . Why are you putting a condition for a order by statement?
Here goes the code,
In the sql I have removed the ORDER BY photo_status_main <> 'main' because i`m not quite sure about your requirement in that.
$file_path = 'http://www.mysite.com/holidays/files/photo_big/';
$sql = 'SELECT photo_id, photo_caption_1 FROM listing_photo WHERE photo_listing = 136 LIMIT 0, 10';
$row = mysql_query($sql);
$noOfRecs = mysql_num_rows($row);
while($result = mysql_fetch_array($row))
{
$files[] = array('id' => $result['photo_id'], 'caption' => $result['photo_caption_1']);
}
$noOfCols = 3;
$totalRows = ceil($noOfRecs / $noOfCols);
$actualNeed = $totalRows * $noOfCols;
print '<table border="1" width="100%">';
$x = 0;
for($i=0; $i < $noOfRecs;$i++)
{
if($x==0)
print '<tr>';
echo '<td><div class="Image"><img src="'. $file_path . $files[$i]['id'] .'.jpg" alt="'. $files[$i]['caption'] .'" title="'. $files[$i]['caption'] .'" height="213" width="300"/>';
echo '<br />';
echo '<span><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">'. $files[$i]['caption'] .'</font></span></div></td>';
$x++;
if($x == $noOfCols)
{
print '</tr>';
$x=0;
}
}
if($actualNeed > $noOfRecs)
{
for($i=$noOfRecs; $i < $actualNeed;$i++)
print '<td> </td>';
print '</tr>';
}
print '</tabel>';