Hi all,
I've got a silly problem at the moment, i'm querrying 1 table in the database retriving all the matching IDs then I'm running another querry against a different table thus leaving me with a set of results. now I know the first querry is working, and that the second is retriving an array of results (because they are printed when I do an echo to the page) but when I try and loop the output of the results to the page I can either get all the houses or only get the last result displayed.
code is below this gives all the houses.
<?php
$databasename = //removed; //start of connection string
$username =//removed;
$password = //removed;
$Hostname = 'localhost';
$linkdb = mysql_pconnect($hostname, $username, $password); //start connection
mysql_select_db($databasename, $linkdb); //connection
$query_date = sprintf("select houseID FROM reservations WHERE in_out < 1 AND date <= $dateleave AND date >= $datearrive"); //retriving the house IDs
$propavailable = mysql_query($query_date, $linkdb) or die(mysql_error()); //execute querry
$row_prop = mysql_fetch_assoc($propavailable); //retrive the array of results
///////////////////////////////////
?>
<?php do { //start loop
mysql_select_db($databasename, $linkdb); //connection to database
$houseid = $row_prop['houseID']; //set the house ID to be one from the array from first set of results
$query_house = sprintf("SELECT houseID, picture, picture2, beds, baths, sleeps, pool, outlook, rating FROM houses WHERE houses.houseID = '$houseid' && houses.outlook ='$outlook' && houses.sleeps ='$sleeps'");
$house = mysql_query($query_house, $linkdb) or die(mysql_error()); //execute querry
$row_houses = mysql_fetch_assoc($house); //get array
echo $row_houses['houseID'];
//}while ($row_prop = mysql_fetch_assoc($propavailable));
$totalRows_houses = mysql_num_rows($house);
?>
</p>
<table cellpadding="0" cellspacing="0" border="0" width="660" height="175" id="table18">
<tr>
<td> <img alt="" src="file:///C:/dev2004p/images/MsoPnl_Cnr_tl_14.gif" width="20" height="20"></td>
<td bgcolor="#0199CC" nowrap width="620"> <font color="#FFFFFF" face="Verdana" size="2">The
homes below are available and match your search criteria:</font></td>
<td height="20" width="20"> <img alt="" src="file:///C:/dev2004p/images/MsoPnl_Cnr_tr_16.gif" width="20" height="20"></td>
</tr>
<tr> <?php do { ?>
<td valign="middle" bgcolor="#E1F2F2" colspan="3" height="135"> <table width="100%" id="table29">
<tr>
<td width="141"><img src="<?php echo $row_houses['picture'] //load picture url as image source?>"></td>
<td width="231"><p align="left" class="bodytext"> <font size="1" face="Verdana">Number
of beds: </font><font size="1" face="Arial, Helvetica, sans-serif"><?php echo $row_houses['beds']; //print bed number?></font>
<p align="left" class="bodytext"><font size="1" face="Verdana">Sleeps:
</font><font size="1" face="Arial, Helvetica, sans-serif"><?php echo $row_houses['sleeps'];//print sleeps ?></font></td>
<td width="205"><p align="left" class="bodytext"> <font size="1" face="Verdana">Number
of bathrooms: </font><font size="1" face="Arial, Helvetica, sans-serif"><?php echo $row_houses['baths'];//print baths ?></font></p></td>
<td><p align="left" class="bodytext"><font size="1" face="Verdana">Pool
type: </font><font size="1" face="Arial, Helvetica, sans-serif"><?php echo $row_houses['pool']; //print pool type ?></font></p></td>
</tr>
<tr>
<td><font size="1" face="Verdana">Outlook: </font><font size="1" face="Arial, Helvetica, sans-serif"><?php echo $row_houses['outlook']; //print outlook ?></font></td>
<td><font size="1" face="Verdana">Rating :</font><font size="1" face="Arial, Helvetica, sans-serif"><?php echo $row_houses['rating']; ?></font><font size="1" face="Verdana">Star </font></td>
<td width="65"><a href="javascript:openNewWin('<?php echo $row_houses['houseID']; ?>')"><img src="detail.jpg" border="0"></a>
</td>
<td width="168"><a href="reserving.php?recordID=<?php echo $row_houses['houseID']; //send house ID ?>&datearrive=<?php echo $datearrive;?>&dateleave=<?php echo $dateleave; ?>&datearriveform=<?php echo $datearriveform;?>&dateleaveform=<?php echo $dateleaveform; ?>"><img src="reserve.jpg" border="0"></a></td>
</tr>
</table></td>
</tr>
<tr>
<td width="20"> <img alt="" src="file:///C:/dev2004p/images/MsoPnl_Cnr_bl_115.gif" width="20" height="20"></td>
<td nowrap bgcolor="#B9E1E1" height="20" colspan="2"> <font size="2">click
<a href="resultsall.php?&datearrive=<?php echo $datearrive; //date arrive?>&dateleave=<?php echo $dateleave; //dateleave?>&datearriveform=<?php echo $datearriveform; //form version of the date?>&dateleaveform=<?php echo $dateleaveform; //form version of leaving date ?>">here</a>
to expand your search</font></td>
</tr> <?php }while ($row_houses = mysql_fetch_assoc($house));
}while ($row_prop= mysql_fetch_assoc($propavailable));
?>
</table>
<p>
any help would be greatly appreciated. I'm sure its something simple.🙂
Rich