I have a table named OPERATORI and anothe one calle OPERATORI DEFUNTI
parsing an xml I'm able to put id and name in OPERATORI but I need to put also in OPERATORI DEFUNTI the same ID I put in OPERATORI
here is my code:
$results = mysql_query("SELECT ID FROM OPERATORI");
while ($row = mysql_fetch_assoc($results))
{
$sql = "INSERT INTO OPERATORI DEFUNTI VALUES ('$row','')";
mysql_query($sql);
}
But the result in OPERATORI DEFUNTI IS array,0
$row
is an array. To insert the ID into table. You need to do this:
$sql = "INSERT INTO OPERATORI DEFUNTI VALUES ('$row[ID]','')";
Edit
As of PHP version 5.5, the use of mysql extension is deprecated. You might want to use mysqli or pdo (To compare both, read MySQL: choosing an API.
And as mentioned in the comment, it's not safe to execute query by joining value to it. Use prepare statement for it. Look at mysqli::prepare or PDO::prepare depends on your choice.