Query 1 table using query results of another table
Posted: Fri May 26, 2006 5:23 am
Hello,
I'm a newbie to php / mysql.
My Situation:
I have successfully queried 1 table. My code is listed below. Now I want to use the query results of this table to query another table. Then I want to display the results of the second query. How do I do this?
Additional Information:
The other table is called developer & there are 3 fields in it. The field names are name, development & type. So the results of field company should query name. The results of field project should query development. The results of field property should query type.
I'm a newbie to php / mysql.
My Situation:
I have successfully queried 1 table. My code is listed below. Now I want to use the query results of this table to query another table. Then I want to display the results of the second query. How do I do this?
Code: Select all
<?php
$username="abc23";
$password="abc23";
$database="abc23";
$host="localhost";
mysql_connect ("$host","$username","$password");
mysql_select_db($database) or die( "Where's the database man?");
$mktime = date('Y-m-d');
$query1=("SELECT * FROM developer_log WHERE expiry > '$mktime'");
$result1=mysql_query($query1);
$num=mysql_num_rows($result1);
while ($row1 = mysql_fetch_array($result1))
{
echo"<b>Main Location: </b> ".$row1['id'].
"<p><b>Sub Location: </b> ".$row1['company'].
"<p><b>Percentage of Malays: </b> ".$row1['project'].
"<p><b>Percentage of Chinese: </b> ".$row1['property'].
"<p><b>Percentage of Indians: </b> ".$row1['email'].
"<p><b>Percentage of Others: </b> ".$row1['cc_email'].
"<p>"
;
}
?>The other table is called developer & there are 3 fields in it. The field names are name, development & type. So the results of field company should query name. The results of field project should query development. The results of field property should query type.