An extra comma is inserted in the beginning. Since I put for ($getTds = 1 instead of for ($getTds = 0. Here: $tdarr[$getTds]= implode(", ", $tds); PHP: in $tds = array(); //to put each record together to pass it on to the $sql $tds[]=""; if($_GET["no"]==NULL){ for ($getTds = 1; $getTds < 1000; $getTds++) {// this divides the tds into 1000 to make it easier to insert in the db table if ($getTds % 10 !== 0) {//if not a multiple of 10 $tds[].= "'".$tdInnerHTML[1][$getTds]."'"; //echo "<span style=\"font-weight: bold;\">" . $getTds . ")</span>" .$tdInnerHTML[1][$getTds]. " ";//lays out the data }else{//if a multiple of 10 $tdarr[$getTds]= implode(", ", $tds); echo $tdarr[$getTds]."<br />\n"; //$sql = "INSERT INTO ".$acronym." (".$fieldarr.") VALUES (".$tdarr[$getTds].")"; //echo $sql."\n"; //mysql_query($sql) or die(mysql_error()); $tds=array(); //empties the previous array content } } } PHP:
But then the next occurrence of $tds[] is $tds[].= "'".$tdInnerHTML[1][$getTds]."'"; Won't there be an error?
califmerchant option is a good option, by I think you have done this wrong. What you have just done is the following things, lets create an array named tds, than create a cell and sets its value to a null string. Now some stuff loop: if .. set a new cell .. else get the array into and remove everything. You should remove the $tds[]=""; and change the $tds[].= to $tds[]=.