3 回答

TA貢獻1797條經驗 獲得超6個贊
試試這個代碼,它對我有用
<?php
for($i=1;$i<=25;$i++)
{
echo "<tr>";
for ($j=1;$j<=5;$j++)
{
echo "<td>$i * $j = ".$i*$j."</td>";
}
echo "</tr>";
}
?>

TA貢獻1856條經驗 獲得超5個贊
根據:
for ($i = 1; $i < 26, $i++) { $productIDs = $ POST['ProductID ' . $我]; };
如果您需要在服務器端擁有一系列已發布的產品:
$postedProducts = [];
for ($i = 1; $i < 26; $i++) {
$currProductID = "ProductID_$i";
if (isset($_POST[$currProductID])) {
$postedProducts[] = $_POST[$currProductID];
}
}
不過,我不明白為什么你需要閱讀$_POST。通常,具有出現在用戶輸入中的id的產品用于編輯或選擇操作。
如果確實有任何數據發布,并且是為了檢查所選產品,則檢查特定產品 ID 是否發布$selectedProductIDs[] = $i;在if塊中就足夠了。

TA貢獻1808條經驗 獲得超4個贊
你可以試試這個代碼。這段代碼肯定有效。
<!DOCTYPE html>
<html>
<head>
<title>Table using php</title>
</head>
<body>
<table border="1">
<thead>
<tr>
<th>ProductID</th><th>ProductPrice</th><th>Discount%</th><th>ShippingOption</th><th>PaymentType</th>
</tr>
</thead>
<tbody>
<?php
$tableStr = "";
for($rows=1;$rows<=25;$rows++)
{
$tableStr += "<tr>";
$tableStr += "<td>".$_POST['ProductID_'.$rows]."</td>";
$tableStr += "<td>".$_POST['ProductPrice_'.$rows]."</td>";
$tableStr += "<td>".$_POST['Discount_'.$rows]."</td>";
$tableStr += "<td>".$_POST['ShippingOption_'.$rows]."</td>";
$tableStr += "<td>".$_POST['PaymentType_'.$rows]."</td>";
$tableStr += "</tr>";
}
?>
</tbody>
</table>
</body>
</html>
- 3 回答
- 0 關注
- 207 瀏覽
添加回答
舉報