-
-
Save bhenry/702221 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
$db = mysql_connect("localhost", "bdag", "bdag") or die("Could not connect."); | |
if(!$db) | |
die("no db"); | |
if(!mysql_select_db("bdaginventory",$db)) | |
die("No database selected."); | |
$handle = fopen("vehicles.csv", "r"); | |
// Read first (headers) record only) | |
$data = fgetcsv($handle, 1000, ","); | |
$sql= 'CREATE TABLE inventorytest ('; | |
$comma = ""; | |
for($i=0;$i<count($data)-1; $i++) { | |
$sql .= $comma . $data[$i].' VARCHAR(0)'; | |
$comma = ", "; | |
} | |
//The line below gets rid of the comma | |
//$sql = substr($sql,0,strlen($sql)-2); | |
$sql .= ');'; | |
mysql_query($sql); | |
echo $sql; | |
echo "done"; | |
fclose($handle); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment