如何使用表中的删除链接从会话数组中删除值。
//在文件A中
< ?php
$_SESSION['cart']['prices'][] = "1000";
$_SESSION['cart']['services'][] = "game 1";
$_SESSION['cart']['prices'][] = "2000";
$_SESSION['cart']['services'][] = "game 2";
$_SESSION['cart']['prices'][] = "3000";
$_SESSION['cart']['services'][] = "game 3";
$_SESSION['cart']['prices'][] = "4000";
$_SESSION['cart']['services'][] = "game 4";
?>
//在文件B中
< table border="1">
< thead>
< th style="width: 450px; text-align:center;">Services< /th>
< th style="width: 450px; text-align:center;">Price< /th>
< th style="width: 450px; text-align:center;">Delete item< /th>
< /thead>
< tbody>
< ?php
foreach ($_SESSION['cart']['services'] as $key => $service) {
echo "< tr>< td>".$service."< /td>< td style='text-align:center;'>".$_SESSION['cart']['prices'][$key]."< /td>< td>ckick to remove< /td>< /tr>";
}
?>
< /tbody>
< /table>
答案 0 :(得分:0)
使用while ($row = mysqli_fetch_array($result)) {
// not needed. if (!mysqli_connect_errno($con)) {
$sqlQueryStr = "UPDATE crewlist SET crew_name = '$CrewName', crew_rank = '$CrewRank', start_date = '$StartDate' "
. ", end_date = '$EndDate', payroll_no = '$PayrollNo'"
. ", employee_no = '$EmployeeNo', watchkeeping = '$WatchKeeping', active = '$Active' WHERE crew_id = " . $row['crew_id'] . "";
//} closing bracket of if, but the if is not needed.
mysqli_query($con, $sqlQueryStr);
}
//after updating all rows, redirect
header('Location: crewlisting.php');
mysqli_close($con);
重置会话值:
unset()