I am trying to display info from 2 tables in a search result format.
My problem is... how do I get the variables to display together?
for example:
A user selects a city to search apartments in.
$sql = "SELECT * FROM $table_name WHERE apt_city = \"$apt_city\"
";
$result = mysql_query($sql, $connection);
while ($row = mysql_fetch_array($result)) {
$aptID = $row['aptID'];
$apt_address1 = $row['apt_address1'];
$apt_address2 = $row['apt_address2'];
$apt_zip = $row['apt_zip'];
}
while ($row = mysql_fetch_array($result)) {
$apt_ID = $row['apt_ID'];
$feature1 = $row['feature1'];
$feature2 = $row['feature2'];
$feature3 = $row['feature3'];
}
Now I want to display the approriate data from the apartment next to the features.
so What I am wondering is how can i "group" the appropriate features with the correct
apartment
so say a result may look like this [HTML table]
______________________________________________
Apartment 1 | feature1
apt_address1 | feature2
apt_address2 | feature3
_________________|_____________________________
Apartment 2 | feature1
apt_address1 | feature2
apt_address2 | feature3
_________________|_____________________________
Apartment 3 | feature1
apt_address1 | feature2
apt_address2 | feature3
_________________|_____________________________
Should the 2nd while loop be placed inside the first?
while ($row = mysql_fetch_array($result)) {
$aptID = $row['aptID'];
$apt_address1 = $row['apt_address1'];
$apt_address2 = $row['apt_address2'];
$apt_zip = $row['apt_zip'];
while ($row = mysql_fetch_array($result)) {
$apt_ID = $row['apt_ID'];
$feature1 = $row['feature1'];
$feature2 = $row['feature2'];
$feature3 = $row['feature3'];
}
$table_block .= "[ this contains HTML code for table rows to display data ]";
}
Thanks Much!
olinux