I'm trying to use a foreach statement in PHP to insert data from an array into a SQL database. The array can vary from 40 to 80 lines of data. I'm using the following code:
foreach ($racelap as $lap){
$sql = "insert into laps (RaceID,Lap,time,Temp,Humidity) ";
$sql .= "values ($RaceID,'$lap[0]','$lap[1]',$lap[2],'$lap[3]')";
mysql_query($sql);
}
The code doesn't give me an error, but it only adds the last line of data, and ignores all other data.
The solution is probably simple, but I can't find it myself unfortunately.