Import xls data to MYSQL

mysql_connect(“localhost”,”root”,””) or die(“cannot connect”); mysql_select_db(“db_name”) or die(“cannot find database”); $dataSheetFile=”sample_csv.csv”; $counter=0; if (($handle = fopen($dataSheetFile, “r”)) !== FALSE) { while (($data = fgetcsv($handle, 1000, “,”)) !== FALSE) { $university=htmlentities(trim($data[0])); $faculty=htmlentities(trim($data[1])); $research_sub_group=htmlentities(trim($data[2])); $themenband=htmlentities(trim($data[3])); $street=htmlentities(trim($data[4])); $zipcode=htmlentities(trim($data[5])); $city=htmlentities(trim($data[6])); $website=htmlentities(trim($data[7])); $counter++; mysql_query(“INSERT INTO research_sub_group set university=’$university’, faculty=’$faculty’, research_sub_group=’$research_sub_group’, themenband=’$themenband’, street=’$street’, zip=’$zipcode’,city=’$city’,website=’$website'”); } } echo […]

Open CSV File using PHP

// place this code inside a php file and call it f.e. “download.php” $_GET[‘download_file’]=’websiteData.csv’; $path = $_SERVER[‘DOCUMENT_ROOT’].”/wedev/”; // change the path to fit your websites document structure $fullPath = $path.$_GET[‘download_file’]; if ($fd = fopen ($fullPath, “r”)) { $fsize = filesize($fullPath); $path_parts = pathinfo($fullPath); $ext = strtolower($path_parts[“extension”]); switch ($ext) { case […]

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top