Here's what you need to do. This code won't work obviously, but it's the rough idea of how to make it work.
Basically when you have multiple DB connections established you just pass in an optional mysql link resource to the mysql_query command, which tells php which database connection to run that specific query on:
PHP Code:
// connect to the 1st database that you are trying to update
$linkCities = mysql_connect(blah blah blah);
mysql_select_db("db_name", $linkCities) || die ("Could not select database: " . mysql_error());
// connect to the 2nd database that has the zipcodes
$linkZips = mysql_connect(blah blah blah);
mysql_select_db("db_name", $linkZips) || die ("Could not select database: " . mysql_error());
$city = "Seattle";
$state = "WA";
// Pull the Zip code from the 2nd database
$query = "SELECT * FROM table_name WHERE state=\"$state\" and city=\"$city\"";
$result = mysql_query($query, $linkZips);
while($row = mysql_fetch_assoc($result)) {
// Update the 1st database with the zipcode
$update_query = "UPDATE table_name SET zip = \"" . $row["zip"] . \"" WHERE city = \"$city\" and state = \"$state\"";
$update_result = mysql_query($update_query, $linkCities);
}
mysql_close($linkCities);
mysql_close($linkZips);
You can see more examples and the details of the mysql_query function here:
http://php.net/manual/en/function.mysql-query.php