Hi there.
I’m having a strange problem.
I have two tables… let’s suppose Invoice_Headers and Invoice_Lines. At some point, user want to copy a invoice. First, I will create a new header and than I must copy the lines from the original Invoice to the new.
I use something like this:
$sql = "SELECT fields FROM Invoice_Lines WHERE invoice_header=".$original;
$result=mysql_query($sql, $con);
$nlines = mysql_num_rows($result);
for ($i=0; $i < $nlinhas; $i++) {
mysql_data_seek($result, $i);
$row = mysql_fetch_assoc($result);
$sql2 = "INSERT INTO Invoice_Lines VALUES(".$row["field"]."ETC...";
$result=mysql_query($sql2, $con);
}
This code doen’t work with PHP, but if I copy it and run it in phpMyAdmin, works perfectly.
Any ideas?
Thanks in advance.
Escar
UPDATE:
There are two records to copy… this code inserts only one… can’t figure it out…