Hi again!
I can an array of ids for zip-codes that are within a certain range from a destination. I can print out the different destinations.
However, I would like to print out a list of users belonging to the various zip-codes.
The users are stored in a different database in the table userdata. The following code won't print out any users, although I know there should be two matches.
I'm also completely confused if I should use while-loops or not. Could someone check the syntax of this code please?
Thanks a lot in advance!
Ciao
Sascha
$con1 = mysql_pconnect("$host", "$login_for_db1", "$pass_for_db1");
$querya = "SELECT *, FLOOR($d) AS distance FROM zip HAVING distance < 100 ORDER BY distance ASC";
$resulta = mysql_db_query("$DB1", $query);
while ($ra = mysql_fetch_array($resulta)) {
$zip = $ra["zip"];
$zipid = $ra["zipid"];
$distance = $ra["distance"];
$con2 = mysql_pconnect("$host", "$login_for_db2", "$pass_for_db2");
$queryb = "SELECT * FROM userdata WHERE zipid = '$zipid'";
$resultb = mysql_db_query("$DB2", $queryb);
while ($rb = mysql_fetch_array($resultb)) {
$username = $rb["username"];
print "$username - $distance km<br>";
}
}
I can an array of ids for zip-codes that are within a certain range from a destination. I can print out the different destinations.
However, I would like to print out a list of users belonging to the various zip-codes.
The users are stored in a different database in the table userdata. The following code won't print out any users, although I know there should be two matches.
I'm also completely confused if I should use while-loops or not. Could someone check the syntax of this code please?
Thanks a lot in advance!
Ciao
Sascha
$con1 = mysql_pconnect("$host", "$login_for_db1", "$pass_for_db1");
$querya = "SELECT *, FLOOR($d) AS distance FROM zip HAVING distance < 100 ORDER BY distance ASC";
$resulta = mysql_db_query("$DB1", $query);
while ($ra = mysql_fetch_array($resulta)) {
$zip = $ra["zip"];
$zipid = $ra["zipid"];
$distance = $ra["distance"];
$con2 = mysql_pconnect("$host", "$login_for_db2", "$pass_for_db2");
$queryb = "SELECT * FROM userdata WHERE zipid = '$zipid'";
$resultb = mysql_db_query("$DB2", $queryb);
while ($rb = mysql_fetch_array($resultb)) {
$username = $rb["username"];
print "$username - $distance km<br>";
}
}