Forum Moderators: coopster
if I add more than 3 featured listings its buts the table, so I need to change it so that after 3 listings its starts a new line.
I have no idea so any help would be great.
Thanks in advance.
Here is the code.
<?php
//handles the listing of featured properties
$result = mysql_query("SELECT * FROM homes WHERE featured = 'Y';",$link);
while ($a_row =mysql_fetch_array ($result) )
{
//add commas to price
$a_row[price] = number_format ($a_row[price]);
print "<td align=\"center\">";
print "<a href=\"./propview.php?view=$a_row[id]\"><b><span class=\"welcomtext\">$a_row[title]</span></b></a><BR>";
//select images connected to a given listing
$query = "SELECT * FROM tbl_files WHERE prop_num = $a_row[id] LIMIT 1";
$output = mysql_query("$query",$link);
$count = 0;
while ($image_row =mysql_fetch_array ($output) )
{
print "<a href=\"propview.php?view=$a_row[id]\">";
if ($useGDimg == 1)
{
print "<img src='$homesimgdir"."tn_"."$image_row[prop_num]$image_row[filename]' border=\"1\" width=\"$homeimgw\" alt=\"Photo\" title=\"Click here to discover more about $a_row[title]\" style=\"border: 1px solid #8b0304;\"></a><br>";
}
if ($useGDimg == 0)
{
print "<img src='$homesimgdir$image_row[prop_num]$image_row[filename]' border=\"1\" width=\"$homeimgw\" alt=\"Photo\" title=\"Click here to discover more about $a_row[title]\" style=\"border: 1px solid #8b0304;\"></a><br>";
}
$count++;
}
if ($count == 0)
{
print "<a href=\"./propview.php?view=$a_row[id]\"><img src=\"./images/nophoto.gif\" border=\"0\" width=100 alt=\"View Listing\" style=\"border: 1px solid #8b0304;\"></a><br>";
}
print "$a_row[beds] beds/$a_row[baths] baths<BR>";
print "$currency$a_row[price]";
print "</td>";
}
?>
regards
Danny
echo "<tr>"; // so I start my row before I enter the loop
$count = 0;
while($row = mysql_fetch_assoc($result))
{
$count++;
if ( ($count % 3) == 0)
{
echo "</tr><tr>"; // we close the current row and start another one
}
echo "<td>cell data</td>";
}
// now we need to create the empty cells to fill out the last row
$filled_cells = $count % 3;
for ($i=$filled_cells; $i<3; $i++)
{
echo "<td> </td>";
}
// finally we close our last row
echo "</tr>";