halohalo
bnmbnmbnhjkhjkhjkhjktyutyutyuytutyutyutyhgjgjghjgjghjguytutyry
/
home
/
aramiyarkai
/
public_html
/
admin
/
Upload FileeE
HOME
<?php require('excelReader/excel_reader2.php'); require('excelReader/SpreadsheetReader.php'); require('dbc.php'); if(isset($_POST['Submit'])) { //var_dump($_POST); echo $pid=$_POST['id']; $mimes = ['application/vnd.ms-excel','text/xls','text/xlsx','text/csv','application/vnd.oasis.opendocument.spreadsheet']; if(in_array($_FILES["file"]["type"],$mimes)){ $uploadFilePath = 'uploads/'.basename($_FILES['file']['name']); move_uploaded_file($_FILES['file']['tmp_name'], $uploadFilePath); $Reader = new SpreadsheetReader($uploadFilePath); $totalSheet = count($Reader->sheets()); // echo "You have total ".$totalSheet." sheets". $html="<table border='1'>"; $html.="<tr><th>Title</th><th>Description</th></tr>"; /* For Loop for all sheets */ for($i=0;$i<$totalSheet;$i++){ $Reader->ChangeSheet($i); foreach ($Reader as $Row) { /*list($max) = mysqli_fetch_row(mysqli_query($mysqli,"select max(id) from product_tbl")); $id = $max+1; $product_id = "LDP".$id;*/ list($max) = mysqli_fetch_row(mysqli_query($link,"SELECT MAX(id) AS max FROM `product_tbl`")); $id = $max+1; $product_id1 = "PID".$id.""; $product_id = mysqli_real_escape_string($link,isset($Row[1]) ? $Row[1] : ''); $group_proid = mysqli_real_escape_string($link,isset($Row[2]) ? $Row[2] : ''); $barcode = mysqli_real_escape_string($link,isset($Row[3]) ? $Row[3] : ''); $product_name_en = mysqli_real_escape_string($link,isset($Row[4]) ? $Row[4] : ''); $cat_id = mysqli_real_escape_string($link,isset($Row[5]) ? $Row[5] : ''); $cat_name_en = mysqli_real_escape_string($link,isset($Row[6]) ? $Row[6] : ''); $subcat_id = mysqli_real_escape_string($link,isset($Row[7]) ? $Row[7] : ''); $subcat_name_en = mysqli_real_escape_string($link,isset($Row[8]) ? $Row[8] : ''); $childcat_id = mysqli_real_escape_string($link,isset($Row[9]) ? $Row[9] : ''); $childcat_name_en = mysqli_real_escape_string($link,isset($Row[10]) ? $Row[10] : ''); $mrp_price = mysqli_real_escape_string($link,isset($Row[11]) ? $Row[11] : ''); $selling_price = mysqli_real_escape_string($link,isset($Row[12]) ? $Row[12] : ''); $cost_price = mysqli_real_escape_string($link,isset($Row[13]) ? $Row[13] : ''); $tax = mysqli_real_escape_string($link,isset($Row[14]) ? $Row[14] : ''); $other_tax = mysqli_real_escape_string($link,isset($Row[15]) ? $Row[15] : ''); $shipping_weight = mysqli_real_escape_string($link,isset($Row[16]) ? $Row[16] : ''); $size = mysqli_real_escape_string($link,isset($Row[17]) ? $Row[17] : ''); $unit = mysqli_real_escape_string($link,isset($Row[18]) ? $Row[18] : ''); $quantity = mysqli_real_escape_string($link,isset($Row[19]) ? $Row[19] : ''); $minq = mysqli_real_escape_string($link,isset($Row[20]) ? $Row[20] : ''); $maxq = mysqli_real_escape_string($link,isset($Row[21]) ? $Row[21] : ''); $stock_avail = mysqli_real_escape_string($link,isset($Row[22]) ? $Row[22] : ''); $created_on = mysqli_real_escape_string($link,isset($Row[23]) ? $Row[23] : ''); $sort = mysqli_real_escape_string($link,isset($Row[24]) ? $Row[24] : ''); $type = mysqli_real_escape_string($link,isset($Row[25]) ? $Row[25] : ''); $status = mysqli_real_escape_string($link,isset($Row[26]) ? $Row[26] : ''); $sel = mysqli_query($link,"select * from product_tbl1 where product_id='$product_id'"); $r=mysqli_fetch_object($sel); $n=mysqli_num_rows($sel); /*echo "INSERT INTO `product_tbl` ( `id`, `product_id`, `group_proid`, `barcode`, `product_name_en`, `cat_id`, `cat_name_en`, `subcat_id`, `subcat_name_en`, `childcat_id`, `childcat_name_en`, `mrp_price`, `selling_price`, `cost_price`, `tax`, `other_tax`, `shipping_weight`, `size`, `unit`, `quantity`, `minq`, `maxq`, `stock_avail`, `created_on`, `type`, `status`) VALUES ( '$id', '$product_id', '$group_proid', '$barcode', $product_name_en', '$cat_id','$cat_name_en', '$subcat_id', '$subcat_name_en', '$childcat_id', '$childcat_name_en', '$mrp_price', '$selling_price', '$cost_price', '$tax', '$other_tax', '$shipping_weight', '$size', '$unit', '$quantity', '$minq', '$maxq', '$stock_avail','$created_on', '$type', '$status')"; exit();*/ if($n==0 || empty($product_id)){ $insert = mysqli_query($link,"INSERT INTO `product_tbl` ( `id`, `product_id`, `group_proid`, `barcode`, `product_name_en`, `cat_id`, `cat_name_en`, `subcat_id`, `subcat_name_en`, `childcat_id`, `childcat_name_en`, `mrp_price`, `selling_price`, `cost_price`, `tax`, `other_tax`, `shipping_weight`, `size`, `unit`, `quantity`, `minq`, `maxq`, `stock_avail`, `created_on`, `type`, `status`) VALUES ( '$id', '$product_id1', '$group_proid', '$barcode', '$product_name_en', '$cat_id','$cat_name_en', '$subcat_id', '$subcat_name_en', '$childcat_id', '$childcat_name_en', '$mrp_price', '$selling_price', '$cost_price', '$tax', '$other_tax', '$shipping_weight', '$size', '$unit', '$quantity', '$minq', '$maxq', '$stock_avail','$created_on', '$type', '$status')"); } else{ // echo 2; $insert=mysqli_query($link,"UPDATE `product_tbl` SET `product_name_en`='$product_name_en',`mrp_price`='$mrp_price',`selling_price`='$selling_price',`cost_price`='$cost_price' WHERE product_id='$product_id'"); } if($insert){ // echo "success"; // echo "<br>"; echo "<script>window.location.href='view_product.php?msg=1';</script>"; }else{ echo "$product_name_en failed"; echo "<br>"; } echo "<br>"; } } $html.="</table>"; // echo $html; // echo "<br />Data Inserted in dababase"; } else { die("<br/>Sorry, File type is not allowed. Only Excel file."); } } ?>