-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert.php
More file actions
31 lines (25 loc) · 729 Bytes
/
insert.php
File metadata and controls
31 lines (25 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
include 'connection.php';
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$stmt = $conn->prepare("INSERT INTO `products` (`id`, `name`, `price`, `product_detail`, `image`) VALUES (?, ?, ?, ?, ?)");
$stmt->bind_param("isiss", $id, $name, $price, $product_detail, $image);
// Example data
$id = 2;
$name = 'Air Jordan1 Mid';
$price = 200;
$product_detail = 'Air Jordan1 Mid';
$image = 'Assets/airjordan1mid.jpg';
$stmt->execute();
$id = 3;
$name = 'Air jordan4 retro oxidized green';
$price = 200;
$product_detail = 'Air jordan4 retro oxidized green';
$image = 'Assets/airjordan4retrooxidizedgreen.jpg';
$stmt->execute();
echo 'Inserted';
$stmt->close();
$conn->close();
?>