"; $rs1=mysql($dbname1,$qr); $rs2=mysql($dbname,"select * from $tablename2"); $nrs1=mysql_numrows($rs1); $nf2=mysql_numfields($rs2); echo "database: $dbname
copying $nrs1 records from $tablename1 into $tablename2

"; $qr="insert into $tablename2 ("; $j=0; $first=1; while($j<$nf2): $cn=$j+1; $tmp="from$cn"; /* campi che non sono da copiare sono marcati con una x */ if ($$tmp!="x"): /* dividere i valori con una virgola */ if($first==1): $first=0; else: $qr=$qr+","; endif; $fn = mysql_FieldName($rs2,$j); $ft = mysql_FieldType($rs2,$j); $qr = $qr+ "$fn"; endif; $j++; endwhile; $qr=$qr+") VALUES ("; $qr0=$qr; $k=0; while($k<$nrs1): $qr=$qr0; $j=0; $first=1; while($j<$nf2): $cn=$j+1; $tmp1="from$cn"; /* campi che non sono da copiare sono marcati con una x */ if ($$tmp1!="x"): /* dividere i valori con una virgola */ if ($$tmp1=="d"): if($first==1): $first=0; else: $qr=$qr+","; endif; $tmp=time(); $qr = $qr + "$tmp"; sleep(1); elseif ($$tmp1=="c"): if($first==1): $first=0; else: $qr=$qr+","; endif; $tt = $k+1; $ft = mysql_FieldType($rs1,$cn2); if($ft=="string"): $qr = $qr+ "'$tt'"; else: if($tt==""): $qr = $qr+ "$tt"; else: $qr = $qr+ "0"; endif; endif; else: $cn2=$$tmp1-1; if($first==1): $first=0; else: $qr=$qr+","; endif; $fn = mysql_FieldName($rs1,$cn2); $tmp= mysql_Result($rs1,$k,$fn); $ft = mysql_FieldType($rs1,$cn2); if($ft=="string"): $qr = $qr+ "'$tmp'"; else: if(strlen($tmp)!=0): $qr = $qr+ "$tmp"; else: $qr = $qr+ "0"; endif; endif; endif; endif; $j++; endwhile; $qr=$qr+")"; echo $qr; echo "
"; $rs2=mysql($dbname,"$qr"); if($rs2==-1): echo "record $k not copied
"; else: echo "record $k copied
"; endif; $k++; endwhile; echo "

"; echo "
go on "; echo "

"; mysql_close(); ?>