My problem seems like a rather small one to me, yet, I cannot figure out a proper solution. The Setup: I have a table 'city_locations' with the columns 'country', 'city', 'longitude', 'latitude'. The countrys are given by 2-Letter ISO codes. I want them to be full names.
For this, I have imported the table 'countrycodes', containing only the columns 'name' and 'code'.
$namechange = $con->prepare("UPDATE city_locations SET country=? WHERE country=?");
$list = $con->prepare("SELECT name, code FROM countrycodes");
$list->execute();
$list->bind_result($name, $code);
$namechange->bind_param('ss', $name, $code);
while ($list->fetch()){
while ($namechange->execute()) {}
echo "$code is now $name <br>";
}
I succesfully retrieve all pairs in the (outer) while loop.
$namechange->execute(); however doesn't do anything - I tried it with and without the while loop, tried using LIMIT 0, 10000 in the query (though I'm not entirely sure I understand LIMIT right). With and without the while loop, the statement doesn't do anything. With LIMIT 0, 10000 the statement cannot be preapred properly (gives an error).
I also tried to bind the params new in every step of the while loop - didn't seem to do anything either.
When running the same command from my web interface, it works fine. However, in that case, I have to type all 200+ codes manually. Seems like a bit much work.
Thanks a lot for your help, Kjeld.
EDIT: $con is of type mysqli.