-
Notifications
You must be signed in to change notification settings - Fork 4
/
UpdateTable.php
57 lines (49 loc) · 1.41 KB
/
UpdateTable.php
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
require_once 'inc_OnlineStoreDB.php';
//require_once 'header.php';
echo "<br>";
echo "<table>";
$query = "SELECT * FROM myusernames ORDER by id ASC";
if ($result = mysqli_query($DBConnect, $query)) {
// fetch associative array
while ($row = mysqli_fetch_assoc($result)) {
// printf ("%s (%s)\n", $row["id"], $row["first"], $row["last"]);
$id = $row["id"];
echo "<tr>";
$pold = 'old'.$id;
echo "<th>pold: ".$pold."</th>";
$in_old = $_POST[$pold];
echo "<th>$in_old</th> ";
$pl = 'in_new'.$id;
echo "<th>pl: ".$pl."</th>";
$in_new = $_POST[$pl];
//$in_new = $_POST['$pl'];
echo "<th></th> ";
echo "<th>$in_new</th> ";
echo "<th></th> ";
echo "<th>";
if ($in_new != $in_old)
{
$updquery = "UPDATE myusernames SET last='$in_new' WHERE id = $id";
echo $updquery ;
$DBConnect->query("$updquery");
//printf("Affected rows (UPDATE): %d\n", $DBConnect->affected_rows);
echo "<font size = 4 color = red>".mysqli_error($DBConnect)."</font>";
if (mysqli_affected_rows($DBConnect) == -1)
echo "<br><br><font size = 3 color = red><b><b>update NOT successfull!!!</b></b></font><br><br>";
else
echo " update success! <br>";
}
else
echo "input output the same";
echo "</th>";
echo "</tr>";
}
// free result set
// mysqli_free_result($result);
}
echo "</table>";
// close connection
mysqli_close($DBConnect);
include 'LoadArray.php';
?>