I have a MySQL DB with 2 Tables in particular, "Properties" and "Tenants". Each Table has a unique address Field "propAddress" & "TenAddress".
I have a PHP page with a repeating reigon that lists all properties in the DB.
What I'm trying to do is list all the tenants info to the matching property based on the addresses.
I have it in my mind I should be using the "Where Clause".
Any advise will be greatly appreciated.
mysql_select_db($database_rent, $rent);
$query_RsProp = "SELECT * FROM Properties ORDER BY PropId ASC";
$query_limit_RsProp = sprintf("%s LIMIT %d, %d", $query_RsProp, $startRow_RsProp, $maxRows_RsProp);
$RsProp = mysql_query($query_limit_RsProp, $rent) or die(mysql_error());
$row_RsProp = mysql_fetch_assoc($RsProp);
if (isset($_GET['totalRows_RsProp'])) {
$totalRows_RsProp = $_GET['totalRows_RsProp'];
} else {
$all_RsProp = mysql_query($query_RsProp);
$totalRows_RsProp = mysql_num_rows($all_RsProp);
}
$totalPages_RsProp = ceil($totalRows_RsProp/$maxRows_RsProp)-1;
$colname_Recordset1 = "-1";
if (isset($_GET['TenantId'])) {
$colname_Recordset1 = $_GET['TenantId'];
}
mysql_select_db($database_rent, $rent);
$query_Recordset1 = sprintf("SELECT Properties.Address, Properties.PropId, Tenants.TenantId, Tenants.FirstName1, Tenants.LastName1, Tenants.FirstName2, Tenants.LastName2, Tenants.Phone1, Tenants.Phone2, Tenants.ContractStart, Tenants.ContractEnd, Tenants.RentDueDate, Tenants.Email, Tenants.ContractLink, Tenants.ApartmentNo, Tenants.TenantAdress FROM Properties, Tenants WHERE Properties.PropId AND Properties.Address=Tenants.TenantAdress AND %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $rent) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<style type="text/css">
body {
background-color: #E2E8FF;
}
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<?php do { ?>
<table width="800" border="0">
<tr>
<td width="114"><img src="<?php echo $row_RsProp['ImageLink']; ?>" width="150"/></td>
<td width="625"><p><b><span style='font-size: 20px;' ><?php echo $row_RsProp['Address']; ?> </span></b><br /><?php echo $row_RsProp['City']; ?>, <?php echo $row_RsProp['State']; ?> <?php echo $row_RsProp['Zip']; ?><br />
<?php echo $row_Recordset1['FirstName1']; ?> <?php echo $row_Recordset1['LastName1']; ?><br />
</p>
<p> </p></td>
<td width="20"> </td>
<td width="23"> </td>
</tr><br /><br /> <br />
</table>
<?php } while ($row_RsProp = mysql_fetch_assoc($RsProp)); ?><br /><br />
</form>