nitai panda

nitai panda

  • NA
  • 13
  • 3.4k

rectify error

Jun 29 2015 3:34 AM
<?php
include_once 'config.php';
if(isset($_POST['submit'])){
if($_FILES['csv_data']['name']){
$arrFileName = explode('.',$_FILES['csv_data']['name']);
if($arrFileName[1] == 'csv'){
$handle = fopen($_FILES['csv_data']['tmp_name'], "r");
$data = fgetcsv($handle, 1000, ",");
$fp=fopen($filename,"w");
$sql=mysql_query("select * from demo");
$row=mysql_fetch_assoc($sql);
foreach($data as $name=>$value and $row as $name=>$value)
{
echo $value.'</br>';
echo $name.'</br>';

}

}
fclose($handle);

}
}

?>
<html>
<head>
<title>Stepblogging :: Upload CSV and Insert into Database Using PHP</title>
<script src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.p').hide()
$('#text').click(function(){
$('.p').show()
});

});
</script>

<head>
<body>
<form method='POST' enctype='multipart/form-data'>
<center><table border="5">
<tr>
<td>Upload CSV:</td> <td><input type='file' name='csv_data' /> </td><td><input type='submit' name='submit' value='Import' id="text" /></td></tr>
</table>
</form>
</body>
</html>

Answers (1)