0
I run a query that returns me a list of Ids. With each ID of this list I want to do an Insert in a second table.
My code:
<?php
$db = mysqli_connect("localhost","root","","test") or die("Erro ao conectar na base de dados MySQL!");
$query = "select id from country";
$result = mysqli_query($db, $query);
while ($row = mysqli_fetch_assoc($result)) {
$var = $row["id"];
mysqli_query($db, "insert into testando (numero) values ('$var')");
}
mysqli_close($db);
?>
When executed, only 1 record is inserted into the database. If I run a second time, nothing happens. Where I am missing??
The error may be being caused by your database structure, for example, if number is some pk, it shows neither an error on the screen?
– Costamilam
No...no screen errors. And "number" is not a PK in the table "testing".
– André Raubach