I have searched for a simliar solution to my problem, but I am struggling to find it so please excuse me if this has already been asked. I have my php code as such
foreach($data['cells'] as $row) {
print_r($row);
}
which produces
Array
(
[1] => ASSET ID
[2] => SERIAL IN CAPS
[3] => COMPANYASSETTAG
[4] => DATE RCVD
[5] => MFR
[6] => Type
[7] => MODEL
[8] => PRINTER MODEL COMMENTS
[9] => PART NUMBER
[10] => R ID
[11] => GRADE
[12] => PRICE
[13] => COLOR CAPABLE (Color or Monochrome)
[14] => COSMETICALLY ACCEPTABLE (Yes or No)
[15] => PRINTERCABLEINCLUDED (Yes or No)
[16] => PRINTER TECHNOLOGY (Laser, Inkjet, 4-1 Laser, 3-1 Laser, 4-1 Ink Jet, 3-1 Ink Jet, Dot Matrix, Plotter, Solid Ink, Thermal)
[17] => DUPLEX (Yes or No)
[18] => MULTIFUNCTION (Yes or No)
[19] => COMMENT (reason)
[20] => COSMETICS COMMENT
[21] => PURCHASE ORDER # (Trailer #)
[22] => WAYBILL#
)
Array
(
[1] => CNGYF04230
[2] => CNGYF04230
[3] => MISSING
[4] => 28/12/2012
[5] => Hewlett Packard
[6] => Multi-Function Printers
[8] => 4345X
[9] => Q3943A
[11] => G
[13] => Monochrome
[14] => Yes
[15] => No
[16] => Laser
[17] => Yes
[18] => Yes
[21] => TRDS293
[22] => HM693800
)
As you can see the key's in the second array are missing ones compared to the above array. These correspond to the column. The reason some are missing in the second is because those fields did not contain any data. I want to be able to insert these into the appropriate fields in the table in mysql based on the keys.
For instance
foreach($data['cells'] as $row) {
//print_r($row);
$sql = "INSERT INTO table (asset_id,serial_in-caps...) VALUES ('$row[0]','$row[1]'...)";
}