residential_projects(table name)
id City Project_name
1 1 Residential Property 1
residential_units_details (table name)
id residential_project_id cityId unitType price
1 1 1 1 BHK 50000
2 1 1 2 BHK 100000
3 1 1 3 BHK 150000
Result i need like this
Property id =1
1 BHK = 50000 (price)
2 BHK = 100000 (price)
3 BHK = 150000 (price)
I writen the query like this but i am not getting the correct answer ,how can do pleaase i spend more time on this please tell me solution My query
$unitType = trim($_GET['unitType']);
$first_second_tables = "SELECT * FROM residential_projects res_project JOIN residential_units_details res_unit ON res_project.id = res_unit.residential_project_id WHERE City='1'";
if($unitType!='')
{
$first_second_tables .=" AND (unitType='$unitType')";
}
$sql=mysql_query($first_second_tables);
while($res = mysql_fetch_assoc($sql)){
echo "Proprty ID=".$res['id'].'<br>';
echo "Unittype=" . $res['unitType'].'<br>';
echo "Price=" . $res['price'].'<br>';
}
i am getting answer
Proprty ID=1
Unittype=1
Price=50000
Proprty ID=2
Unittype=2
Price=100000
Proprty ID=3
Unittype=3
Price=150000
i think here printing all datas in second tables i don't know how to get my requirement answer anyone help me
Updated code var_dump($res);
array(3) {
["unitType"]=>
string(1) "1"
["price"]=>
string(5) "50000"
["Project_name"]=>
string(22) "Residential Property 1"
}
array(3) {
["unitType"]=>
string(1) "2"
["price"]=>
string(6) "100000"
["Project_name"]=>
string(22) "Residential Property 1"
}
array(3) {
["unitType"]=>
string(1) "3"
["price"]=>
string(6) "150000"
["Project_name"]=>
string(22) "Residential Property 1"
}
array(3) {
["unitType"]=>
string(1) "4"
["price"]=>
string(4) "4343"
["Project_name"]=>
string(21) "Residential Project 2"
}
array(3) {
["unitType"]=>
string(1) "4"
["price"]=>
string(4) "5353"
["Project_name"]=>
string(21) "Residential Project 2"
}