I Have the following PHP script:
$i = 0;
while ($i < 30){
$insertquery = "INSERT INTO {$savename} VALUES (";
foreach ($valuearray as $column){
$insertquery .= $column[$i] . ",";
}
$insertquery .= ");";
echo $insertquery;
$queryResult = mysqli_query($con, $insertquery);
if ($queryResult === TRUE){
}else{
print "<br /><br />No Row created. Check " . mysqli_error($con);
}
$i++;
}
The $valuearray is a two dimensional array with everything that needs to be inserted into the table. The issue is that the above code creates a MySQL statement in the form
INSERT INTO rates_test VALUES (1000,0.1,2.3,100,2,3,);
Which gives a Syntax error as the last value has a ,
after it.
How could I go about changing the script so that the last value does not have a ,
after it, or prehaps delete it after the foreach loop?