Forum Moderators: coopster
$query = "Select * from contactsitejoin join people on people.personid = contactsitejoin.personid where siteid = $siteid";
$query_result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($query_result);
while($row = mysql_fetch_array($query_result)) {
print "<p><strong>{$row['position']}</strong> {$row['title']}{$row['fname']} {$row['lname']}; ";
To this point, the code works fine. It is returning the expected results.
$query2 = "Select * from personphonejoin where personid = {$row['personid']}";
$query_result2 = mysql_query($query2) or die(mysql_error());
$row2 = mysql_fetch_array($query_result2);
while($row2 = mysql_fetch_array($query_result2)) {
print "Phone: {$row2['phonenumber']} (";
This is where the problem occurs. Nothing is being returned. So far, I have:
1. echoed query2. It is returning the correct query (select * from personphonejoin where personid = 2)
2. printed the results of the query. It is only returning the person id and not the phone number - that is the whole problem!
3. Checked spelling in the db and on the screen - everything matches.
4. Changed select * to select personid, phonenumber - no result.
Everything below here I have not tested because I cannot get beyond query2.
I am using the latest versions of php and mysql. The data types for personid is smallint[6] unsigned for both the phone and personphonejoin tables.
$query3 = "Select * from phone where phonenumber = {$row2['phonenumber']}";
$query_result3 = mysql_query($query3) or die(mysql_error());
$row3 = mysql_fetch_array($query_result);
while ($row3 = mysql_fetch_array($query_result3)) {
print "{$row3['phoneclass']} ";
}
}
print "</p>";
}