Display data from related tables in results
Hi all,
I'm trying to display data in my main results pages from two related tables
prop_details
prop_images
I'd like display all thumbnails from prop_images that are related to prop_details, the relationship being prop_id
I've create a new recordset
<?php
$maxRows_WADAprop_details = 5;
$pageNum_WADAprop_details = 0;
if (isset($_GET['pageNum_WADAprop_details'])) {
$pageNum_WADAprop_details = $_GET['pageNum_WADAprop_details'];
}
$startRow_WADAprop_details = $pageNum_WADAprop_details * $maxRows_WADAprop_details;
mysql_select_db($database_prop, $prop);
$query_WADAprop_details = "SELECT prop_ref, prop_id, add_date, prop_type, short_desc, town, price, status, featured FROM prop_details";
$query_limit_WADAprop_details = sprintf("%s LIMIT %d, %d", $query_WADAprop_details, $startRow_WADAprop_details, $maxRows_WADAprop_details);
$WADAprop_details = mysql_query($query_limit_WADAprop_details, $prop) or die(mysql_error());
$row_WADAprop_details = mysql_fetch_assoc($WADAprop_details);
if (isset($_GET['totalRows_WADAprop_details'])) {
$totalRows_WADAprop_details = $_GET['totalRows_WADAprop_details'];
} else {
$all_WADAprop_details = mysql_query($query_WADAprop_details);
$totalRows_WADAprop_details = mysql_num_rows($all_WADAprop_details);
}
$totalPages_WADAprop_details = ceil($totalRows_WADAprop_details/$maxRows_WADAprop_details)-1;
mysql_select_db($database_prop, $prop);
$query_SelectThumb = "SELECT prop_images.img_thumb, prop_images.prop_id, prop_details.prop_id FROM prop_images, prop_details WHERE prop_images.prop_id = prop_details.prop_id";
$SelectThumb = mysql_query($query_SelectThumb, $prop) or die(mysql_error());
$row_SelectThumb = mysql_fetch_assoc($SelectThumb);
$totalRows_SelectThumb = mysql_num_rows($SelectThumb);
?>
which makes the match (I think)
but I can't get the image file names to display in my table row in the main repeat region
<?php do { ?>
<tr class="<?php echo $WARRT_AltClass1->getClass(true); ?>">
<td class="WADAResultsTableCell"><?php echo($row_WADAprop_details['prop_ref']); ?></td>
<td class="WADAResultsTableCell"><?php echo($row_WADAprop_details['prop_id']); ?></td>
<td class="WADAResultsTableCell"><?php echo($row_WADAprop_details['add_date']); ?></td>
<td class="WADAResultsTableCell">Display all image in series related to the record here<?php echo $row_SelectThumb['img_thumb']; ?></td>
<td class="WADAResultsTableCell"><?php echo($row_WADAprop_details['prop_type']); ?></td>
<td class="WADAResultsTableCell"><?php echo($row_WADAprop_details['short_desc']); ?></td>
<td class="WADAResultsTableCell"><?php echo($row_WADAprop_details['town']); ?></td>
<td class="WADAResultsTableCell"><?php echo($row_WADAprop_details['price']); ?></td>
<td class="WADAResultsTableCell"><?php echo($row_WADAprop_details['status']); ?></td>
<td class="WADAResultsTableCell"><?php echo($row_WADAprop_details['featured']); ?></td>
</tr>
<?php } while ($row_WADAprop_details = mysql_fetch_assoc($WADAprop_details)); ?>
Can anyone help?
Thanks
Phil