hello I'm trying to insert values from an array using PHP into multiple rows in a mysql table.
this is basically what i'm doing:
$x=0;
while($x < 40){ <----the 40 is the size of the array
$nameinsert=$name[$x];
$sql = "INSERT INTO mytable VALUES ('','$nameinsert')";
$x++;
}
return mysql_query($sql);
obviously solutions would be great, but my main question is why doesn't this work? why does it only insert the last value from the array?
from what i can tell it should:
get the value from the array insert into the the table increase value $x then get the next value from the array then insert that into the table
so why doesn't it?