Here's a little example of a Microsoft Outlook address book (csv) upload snippet that I use. An Excel spreadsheet exported into csv format should look similar.
// mapping of Outlook fields to our database fields
$mapping = array(
"First Name" => "fname",
"Last Name" => "lname",
"E-mail Address" => "email",
"Home Street" => "address",
"Home City" => "city",
"Home Postal Code" => "zip",
"Home State" => "state",
"Home Phone" => "phone",
"Home Fax" => "fax",
"Mobile Phone" => "mobile"
);
// first get the order of the fields
$handle = fopen($_FILES['userfile']['tmp_name'], "r");
$data = fgetcsv($handle, 1000, ","); // first line contains our field names
$num = count($data);
for ($i=0; $i<$num; $i++) {
$field[$i] = $mapping[$data[$i]];
}
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { // get a line, insert into table
$query = "INSERT INTO table SET id='0'";
for ($i=0; $i<$num; $i++) {
$query .= ", " . $field[$i] . "='" . addslashes($data[$i]) . "'";
}
mysql_query($query);
}
fclose($handle);