I want to insert 31102 records into a db table from an html table.
I wanted to make it dependent on the number of the page. When page=1 then it would insert the first set of records. WHen it's 2 the 2nd set. This way the browser won't freeze.
PHP Code:$num=round(count($trInnerHTML[1])/32);
echo "<span style=\"color: orange;\">".$num."</span><br />\n";
$limit=($page+1)*$num;
$tds = array();
for($getTds=($page-1)*$num; $getTds<$limit; $getTds++){//counting the trs
if($getTds!==0){
preg_match_all("#<td.*>(.+)</td#Ui", $trInnerHTML[1][$getTds], $tdInnerHTML);
//print_r($tdInnerHTML[1]);
echo "<span style=\"color: red;\">".count($tdInnerHTML[1])."</span>";
//echo "<br />\n";
for($splitTds=0; $splitTds<count($tdInnerHTML[1]); $splitTds++){
if($splitTds!==0){
$tds[] = addslashes($tdInnerHTML[1][$splitTds]);
echo "<span style=\"color: blue;\">".$tdInnerHTML[1][$splitTds]."</span><br /\n>";
}
if($splitTds==count($tdInnerHTML[1])-1){
$tdarr = implode("', '", $tds);
$sql = "INSERT INTO ".$dbTable3." (".$fieldarr.") VALUES ('".$tdarr."')";
echo "<span style=\"color: green;\">".$sql."</span><br /\n>";
mysql_query($sql) or die(mysql_error());
$tds = array();
}
}
}
}
mysql_close($con);
//then redirect them to the index
$add=$page+1;
echo "Location: create_bible.php?type=create&table=bible&page=".$add;
header("Location: create_bible.php?type=create&table=bible&page=".$add);



Reply With Quote







Bookmarks