Ok further to my original post I can now see where I’m going wrong (I think). Having run a few tests I see that
Code: Select all
$query_rstThumbs = "SELECT * FROM images WHERE idpk = '".$row_getProperties['properties_idpk']."'";
is passing to the loop (where the thumbnails are run) a value of the first 'properties_idpk' from the database for example ‘1’ if this is to return all the images then I need something like
Code: Select all
$query_rstThumbs = "SELECT * FROM images ";
Now as this page is preceeded by a set of select boxes I simply can’t remove
Code: Select all
$query_rstThumbs = "SELECT * FROM images WHERE idpk = '".$row_getProperties['properties_idpk']."'";
So what do I do here?
I also now discovered that I’m trying to nest 2 loops further down my code and I don’t think this is possible or at least the way I’m doing this.
I have posted all the code from the page in the hope that some poor soul can help me out. I appreciate this is a big ask but I’m at this for days and as a stubborn beginner I don’t want to give up.
Thanks very much again
B
Code: Select all
<?php
mysql_select_db($********, $**********);
$query_getProperties = "SELECT * FROM properties, locations, bedrooms
WHERE properties.properties_idpk = bedrooms.bedrooms_idpk
And properties.locations_idfk = locations.locations_idpk";
if ($_POST['bedrooms_idpk']) {
$query_getProperties .= ' AND properties.bedrooms_idfk >= ' .stripslashes($_POST['bedrooms_idpk']);
}
if ($_POST['locations_idpk']) {
$query_getProperties .= ' AND locations.locations_idpk = ' .$_POST['locations_idpk'];
}
$getProperties = mysql_query($query_getProperties, $appartments) or die(mysql_error());
$row_getProperties = mysql_fetch_assoc($getProperties);
$totalRows_getProperties = mysql_num_rows($getProperties);
mysql_select_db($database_appartments, $appartments);
$query_rstThumbs = "SELECT * FROM images WHERE idpk = '".$row_getProperties['properties_idpk']."'";
$rstThumbs = mysql_query($query_rstThumbs, $appartments) or die(mysql_error());
$row_rstThumbs = mysql_fetch_assoc($rstThumbs);
$totalRows_rstThumbs = mysql_num_rows($rstThumbs);
mysql_select_db($database_appartments, $appartments);
$query_GetFacilities = "SELECT facilities FROM properties WHERE properties_idpk = '".$row_getProperties['properties_idpk']."'";
$GetFacilities = mysql_query($query_GetFacilities, $appartments) or die(mysql_error());
$row_GetFacilities = mysql_fetch_assoc($GetFacilities);
$totalRows_GetFacilities = mysql_num_rows($GetFacilities);?>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" id="sidecontent">
</td>
<td valign="top" id="midcolumn">
<div id="artwork">
<img src="images/tommy_melonart2.jpg" alt="" width="180" height="164"></div>
</td>
<td valign="top" id="maincontent">
<?php // if no entry is in db, don't show anything not even the table row
if (!empty($row_getProperties)) {
do { ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tblproperty">
<tr>
<td>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="tblbg">Property</td>
</tr>
<tr>
<td><?php echo nl2br($row_getProperties['name']); ?></td>
</tr>
<tr>
<td class="tblbg">Location</td>
</tr>
<tr>
<td><?php echo nl2br($row_getProperties['location']); ?></td>
</tr>
<tr>
<td class="tblbg">Description</td>
</tr>
<tr>
<td><?php echo nl2br($row_getProperties['description']); ?></td>
</tr>
<tr>
<td class="tblbg">Prices</td>
</tr>
<tr>
<td><?php echo nl2br($row_getProperties['prices']); ?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<?php do { ?>
<?PHP
if (isset($row_rstThumbs['ThumbName']) && file_exists('images/apartments/'.$row_rstThumbs['ThumbName'])) {
$image_info_1 = getimagesize('images/apartments/'.$row_rstThumbs['ThumbName']);
}$dims_1 = isset($image_info_1) ? $image_info_1[3] : '';
if (isset($row_rstThumbs['ImageName']) && file_exists('images/apartments/'.$row_rstThumbs['ImageName'])) {
$image_info_large = getimagesize('images/apartments/'.$row_rstThumbs['ImageName']);
}$dims_2 = isset($image_info_large) ? $image_info_large[3] : '';
echo $row_rstThumbs['id'];
if ($dims_1) { ?> <!-- Add +20 to get the image to center in pop up and show close button-->
<a href="gallery_pop.php?image_id=<?php echo $row_rstThumbs['id']; ?>" title="Mogan Puerto"><img src="images/apartments/<?php echo $row_rstThumbs['ThumbName']; ?>" <?php echo $dims_1; }?> alt="Click for a larger image" border="0" onClick="dpSmartLink('gallery_pop.php?image_id=<?php echo $row_rstThumbs['id']; ?>','newWin','<?php echo $image_info_large[0]+ '20'; ?>','<?php echo $image_info_large[1]+ '50'; ?>','100:0',0);return document.MM_returnValue"></a>
<?php } while ($row_rstThumbs = mysql_fetch_assoc($rstThumbs)); ?>
</td>
</tr>
<tr>
<td>12</td>
</tr>
<tr>
<td>12</td>
</tr>
</table>
<?php } while ($row_getProperties = mysql_fetch_assoc($getProperties)); ?>
<?
} else {
echo ("Sorry there are no matches this time in our database. <br><br> <a href='javascript:history.back()'>Click here</a> to Search Again.");} ?>
</td>
</tr>
</table>
</div>
</body>
</html>