员工将输入empID并为其设置会话。当他们进入页面时,会有一个客户列表。当他们点击更新时,它将重定向到更新页面,同时根据custIC创建会话ID。问题是为什么它发送数组中的最后一个custIC而不是我选择的那个?顺便说一句,我使用xampp连接我的数据库。
<?php
session_start();
require "lowkosDB.php";
?>
<?php
$empID = $_POST['empID'];
$password = $_POST['password'];
$selectsql = "SELECT *
FROM employee
WHERE empID = '$empID'
AND password = '$password';";
$result = mysql_query($selectsql);
$numRows = mysql_num_rows($result);
$row = mysql_fetch_array($result);
$id = $row['empID'];
$selectsql2 = "SELECT * from customer C, employee E, item I, reference R, service S
WHERE R.custIC = C.custIC
AND R.itemNo = I.itemNo
AND R.servNo = S.servNo
AND R.empID = E.empID
ORDER BY refNo;";
$result2 = mysql_query($selectsql2);
$numRows2 = mysql_num_rows($result2);
$row2 = mysql_fetch_array($result2);
if($numRows > 0) {
print "Welcome back, $row[empName]<br>";
print "What to do next?<br>";
print "<a href=update.php?empID=$id>Update</a><br>";
print "<a href=delete.php?empID=$id>Delete</a><br>";
$_SESSION['empID'] = $id;
print "Your session id is ".$_SESSION['empID'];
print "<table border=1 ><tr align=center><th>Reference No</th>";
print "<th>Customer IC</th>";
print "<th>Customer Name</th>";
print "<th>Item No</th>";
print "<th>Service No</th>";
print "<th>Technician ID</th>";
print "<th>Progress</th></tr>";
$c = 0;
while($row2 = mysql_fetch_assoc($result2)) {
echo "<tr align=center><td>$row2[refNo]</td>";
echo "<td>$row2[custIC]</td>";
echo "<td>$row2[custName]</td>";
echo "<td>$row2[itemNo]</td>";
echo "<td>$row2[servNo]</td>";
echo "<td>$row2[empName]</td>";
echo "<td>$row2[progress]</td>";
$cust[$c] = $row2['custIC'];
echo "<td><a href=update.php?custIC[$c]=$cust[$c]>UPDATE</a></td></tr>";
$c = $c + 1;
echo "$c"; }
print "</table>";
print "<br/>Register a new customer? Click <a href=insert.php>HERE</a>";
for($i=0;$i<$c;$i++) {
echo $cust[$i];
}}
else
print "Login unsuccessful. Please <a href=login.php>Re-Login</a>";
?>