]]jkjjgdjffksdkdxmnvbcbcvbvcbbbbbbbbbvcbcbvcbmnmbnwqeqwewqskfgj
במ12[cvbnvbnvcvbcvbcvbvvvccccccccccccccvbcvbcvbnmnmqewv;'
/
home
/
u729855735
/
domains
/
stylebyou.com
/
public_html
/
admin
/
Upload FileeE
HOME
<?php // Database connection settings $host = "localhost"; $username = "root"; $password = ""; $database = "vitamin"; // Establish database connection $conn = new mysqli($host, $username, $password, $database); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } if (isset($_POST['submit'])) { // Check if a CSV file was uploaded if (isset($_FILES['csv_file']) && $_FILES['csv_file']['error'] == 0) { $csv_file = $_FILES['csv_file']['tmp_name']; // Open the CSV file if (($handle = fopen($csv_file, "r")) !== FALSE) { while (($data = fgetcsv($handle, 0, ",")) !== FALSE) { $column1 = $data[0]; $column2 = $data[1]; $column3 = $data[2]; $column4 = $data[3]; $column5 = $data[4]; $column6 = $data[5]; $column7 = $data[6]; $column8 = $data[7]; $query = "SELECT * FROM product WHERE sku = '$column1'"; $result = $conn->query($query); if ($result->num_rows > 0) { $updateQuery = "UPDATE product SET sku= '$column1', pr_nm = '$column2', pr_price = '$column3', sale_price = '$column4', pr_img = '$column5', pr_desc = '$column6', status = '$column7' WHERE sku = '$column1'"; $conn->query($updateQuery); } else{ $sql = "INSERT INTO product (sku,pr_nm,pr_price,sale_price,pr_img,pr_desc,status) VALUES ('$column1', '$column2', '$column3','$column4','$column5','$column6','$column7')"; if ($conn->query($sql) === TRUE) { } else { echo "Error: " . $sql . "<br>" . $conn->error; } } } fclose($handle); echo "<script>alert('Data imported successfully.');location.href='import.php'</script>"; } else { echo "Error opening the CSV file"; } } else { echo "No CSV file uploaded or an error occurred during upload"; } $conn->close(); } ?>