Hi, I’m still new, but I have learned here in the past so I’m back to ask more questions ?
I’m trying to make an upload script where a CSV file will be imported into a database. to make this simple I’m going to use two fields, Title,Description
so I have a csv file like:
[CODE]Title,Description
Test title,Test description
Test title,Test description
being the header and fields. I searched here and online and found the following script:
[code=php]$columns = “`c1` , `c2`”;
$handle = fopen(“test.csv”, “r”);
while (($data = fgetcsv($handle, 1000, “,”)) !== FALSE) {
foreach( $data as $v ) {
$insertValues=”‘”.addslashes(trim($v)).”‘”;
}
$values=inplode(‘,’,$insertValues);
$sql = “INSERT INTO `tableName` ( $columns ) VALUES ( $values )”;
mysql_query($sql) or die(‘SQL ERROR:’.mysql_error());
}
fclose($handle);
I’m still new but I take it the “inplode” above is “implode”….In the test example above would the $columns c1, c2 be the header fields(title, description) or the values test title, test description? I take it they are the header….so I would take the database name, ie database_title and replace “c1” with it, correct? I’m sure I’ll have more questions but I want to understand what’s going on step by step here.