this is Ryham, I am a newbie at code writing and that code I need to know what makes it run successfully but for only one row in my csv file. Code goes as follows. Thank you for any help with this. (:
<?php
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
ini_set('max_execution_time',0);
ini_set('upload_max_filesize', '50M');
ini_set('post_max_size', '50M');
ini_set('max_input_time', 0);
ini_set("memory_limit", "-1");
set_time_limit(0);
$ip = getenv('REMOTE_ADDR');
$conn=mysqli_connect("somehost","someusr","somepassword", "somebd") or die("Could not connect");
if(isset($_POST["submit_file"]))
{
$op = $_POST['op'];
$month = $_POST['month'];
$year = $_POST['year'];
$file = $_FILES["file"]["tmp_name"];
$file_open = fopen($file,"r");
while(($csv = fgetcsv($file_open,1000, ",")) !== false)
{
$ct = $csv[0];
$ts = $csv[1];
$cd = $csv[2];
$pc = $csv[3];
$query="INSERT INTO anew(`ct`, `ts`, `cd`, `pc`, `uploadedby`, `op`, `month`, `year`) VALUES ('$ct','$ts','$cd','$pc','$ip', '$op', '$month', '$year'); update anew set wtd = true";
$result= $conn->multi_query($query);
if($result)
{
echo "<script type=\"text/javascript\">
alert(\"file is upload successfully\");
window.location.href = '/insights/datauploader/';
</script>";
}
else{echo"<script type=\"text/javascript\">
alert(\"there is some error\");
window.location.href = '/insights/datauploader/';
</script>";}
}
}
?>