-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddTag.php
More file actions
32 lines (27 loc) · 883 Bytes
/
Copy pathaddTag.php
File metadata and controls
32 lines (27 loc) · 883 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
32
<?php
echo $_SERVER['PHP_SELF'];
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "onlineShopping";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$pid = 27;
$a = array("electronics", "philips", "vacuum", "cleaner", "vacuumcleaner");
for($i=0; $i < count($a); $i++) {
echo ("select TagID from tag where TagName = '".$a[$i]."'"."</br>");
$b = $conn->query("select TagID from tag where TagName = '".$a[$i]."'") or die("ersdf");
$c = null;
while($row = $b->fetch_assoc()) {
$c = $row["TagID"];
}
echo ("insert into tagProduct values(".$pid.",".$c.")"."</br>");
$conn->query("insert into tagProduct values(".$pid.",".$c.")")or die("ersdf2");
}
$conn->close();
echo "done";
?>