2016-03-04 68 views
-1

我正在將我的數組列表中選定的項目發佈到新的php頁面。但是,我有地方會話來測試會話是否正常工作。到目前爲止。但是,我無法想出將所選數組獲取到新頁面的方法。將選定數組發佈到新的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

不知道你想在這裏實現什麼。到目前爲止,您並未在表單中提交任何數據。有關會議的更多信息,請參閱文檔:http://php.net/manual/en/intro.session.php – Fin

+0

我想將多維初始鍵分配給數組中的複選框值。有沒有辦法呢? – AMMOTECH

回答

0

如果你想分配多維初始密鑰進行陣列內的複選框值,添加第二行到您的第一個for循環:

for($i = 0; $i < count($arrCustInvoices); $i++){ 
    $arrCustInvoices[$i][7] = "<input action=\"Post\" type=\"checkbox\" name=\"checkbox\" value=\"".$i."\" id=\"checkbox\">"; 
} 

這條線將改寫輸入標籤字符串並在其中添加迭代器。