[eluser]the_unforgiven[/eluser]
Right ok think i kinda got ya, before i do these error checking etc just wanted to show you what code i currently have:
Code:
$table = 'wc_program';
$image_data = $this->upload->data();
$fname = $image_data['file_name'];
$fpath = $image_data['file_path'].$fname;
$fh = fopen($fpath, "r+");
$headers = 1;
$insert_str = 'INSERT INTO wc_program (JobRef, Area, Parish, AbbrWorkType, WorkType, Timing, TrafficManagement, Location, Duration, Start, Finish) VALUES '."\n";
if ($fh && $headers == 1) {
// Create each set of values.
while (($csv_row = fgetcsv($fh, 1000, ',')) !== false) {
foreach ($csv_row as &$row) {
$row = strtr($row, array("'" => "\\'", '"' => '\\"'));
}
$insert_str .= '("'
// Implode the array and fix pesky apostrophes.
.implode('","', $csv_row)
.'"),'."\n";
}
// Remove the trailing comma.
$insert_str = rtrim($insert_str, ",\n");
// Insert all of the values at once.
$this->db->query($insert_str);
$this->layout->buffer('content', 'program/success');
$this->layout->render();
}
So where would i put the strip headers thingy