// Connect to the MySQL server and select the corporate database
$mysqli = new mysqli("localhost","user,"password,"test");
// Open and parse the test.txt file
$fh = fopen("test.txt", "r");
while($line = fgetcsv($fh, 1000, ","))
{
$id = $line[0];
$item = $line[1];
$price = $line[2];
// Insert the data into the sales table
$query = "INSERT INTO example SET id='$id',
item='$item', price='$price'";
$result = $mysqli->query($query);
}
fclose($fh);
mysqli_close();
?>
Last edited by peter_budo; Oct 22nd, 2009 at 2:18 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.