我正在将我的数组列表中的所选项目发布到新的php页面。但是,我有会话来测试会话是否正常工作。到目前为止。但是,我无法想到一种方法来获取所选数组到新页面。
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Pizza Orders</title>
<!--
-->
<meta charset="utf-8">
<meta name="author" content="">
<meta name="robots" content="NOINDEX, NOFOLLOW">
<style type="text/css">
body {
margin: 10px;
padding: 25px;
background-color: bisque
}
.formLayout {
background-color: #f3f3f3;
border: solid 1px #a1a1a1;
padding: 10px;
width: 300px;
height: 115px;
}
.formLayout label, .formLayout input {
display: block;
width: 120px;
float: left;
margin-bottom: 10px;
}
.formLayout label {
text-align: right;
padding-right: 20px;
}
#cmdSubmit {
margin: 0 100px;
}
.example {
font-family: monospace;
color: green;
font-size: larger;
font-weight: bold;
}
.phpEcho {
background-color: orange;
border: thin black solid;
padding: 25px;
}
br {
clear: both;
}
</style>
</head>
<body>
<h2>Pizza Orders</h2>
<div class="phpEcho">
<?php
// build the multidimensional array
$arrCustInvoices = array
(
array("02/28 8:30 p.m.", "Small, hand tossed: MeatLovers: pepperoni, sausage, hamburger", 16.55, 1.55, 18.10, "Robert Elias", "400 w. 10th, Anaheim", "<input action=\"Post\" type=\"checkbox\" name=\"checkbox\" value=\"\" id=\"checkbox\">"),
array("02/28 8:43 p.m.", "Large, hand tossed: Veggie: onion, mushroom, tomatoe", 11.55, 1.25, 12.80, "Bob Harper", "123 w. main st., Anaheim", "<input action=\"Post\" type=\"checkbox\" name=\"checkbox\" value=\"\" id=\"checkbox\">"),
array("02/28 8:51 p.m.", "Medium, Deep Dish: Build Your Own: pepperoni, tomatoe", 13.55, 1.35, 14.90, "Frank Lopez", "385 n. Salute ave, Tustin", "<input action=\"Post\" type=\"checkbox\" name=\"checkbox\" value=\"\" id=\"checkbox\">"),
);
// count the number of indexes in the multidimensional array
$intNumIndexes = count($arrCustInvoices);
// create a count for the number of invoices pulled
$intCount = 0;
print "<h3>Undelivered Pizzas</h3>";
print "<table border=\"1\" padding=\"10px\" width=\"90%\">";
print "<tr>";
print "<th>Item Number</th><th>Date/Time</th><th>Pizza Type</th><th>Price</th><th>Tax</th><th>Total</th>"
. "<th>Customer Name</th><th>Address</th><th>Delivered</th>";
print "</tr>";
// use the for to loop through the indexes
for ($i = 0; $i < $intNumIndexes; $i++){
// create a row for each invoice
echo "<tr>";
// indexes start at 0, so up the count by 1 to display a logical number in the table
$intItem = $i + 1;
// display the item number
echo "<td align=\"center\">$intItem</td>";
// loop through each of the multidimensional array indexes and display them in a table cell
for ($j = 0; $j < 9; $j++){
echo "<td align=\"center\">";
echo $arrCustInvoices[$i][$j];
echo "</td>";
}
// close the row
echo "</tr>";
// up the count for summary purposes
$intCount++;
}
//$arrCustInvoices = filter_input(INPUT_POST, "checked");
//$result = $arrCustInvoices[$arrCustInvoices];
// display the count for summary
$_SESSION['session_var'] = "testing";
echo "<form method=\"POST\" action='completeOrder.php'><tr><td colspan=\"10\" align=\"center\"><input type='submit' value='Selected Pizzas Delivered'></form></td></tr>";
echo "<tr><td colspan=\"10\" align=\"right\">Total Number of Invoices: " . $intCount . "</td></tr>";
?>
</div>
</body>
</html>
答案 0 :(得分:0)
如果您尝试将多维初始键分配给数组中的复选框值,请将第二行添加到第一个for循环中:
for($i = 0; $i < count($arrCustInvoices); $i++){
$arrCustInvoices[$i][7] = "<input action=\"Post\" type=\"checkbox\" name=\"checkbox\" value=\"".$i."\" id=\"checkbox\">";
}
该行将重写输入标记字符串并在其中添加迭代器。