[請益] php撈取html中check的值帶進for loop
小弟我遇到了個問題
可能對各位來說很簡單
但是因為小弟我不熟php+mysql
所以請教各位一下
目前html中設定有10個check按鈕
然後當我按下按鈕之後
譬如按了兩個, 所以傳去.php的value就是1(第一個是0)
我在.php裡面也収得到這個數值
$item=$_POST['item'];
echo $item; <==就是前面說的value
但是
當我要用這個$item丟進去for loop的時候
他卻甚麼反應都沒有
這個for loop的目的
是讓使用者點幾個check就用幾行的輸入
其他沒有點到的即使有輸入進去數值也不理會
以下是程式碼
我想應該是for loop寫的方法有問題吧!?
因為不管$item是甚麼數值 最後顯示只有第一筆資料
也就是$url[0],$p[0]...這些第一筆可以顯示
$url[1],$p[1]卻不能顯示
請問是哪邊出了問題呢?
for ($x = 0; $x < $item; $x++)
{
$url[$x]=$_POST['TAOBAO_URL'][$x];
$p[$x]=$_POST['PRICE'][$x];
$num[$x]=$_POST['NUMBER'][$x];
$dp[$x]=$_POST['DELIVERY_PRICE'][$x];
$ia[$x]=($p[$x]*$num[$x])+$dp[$x];
$comment[$x]=$_POST['COMMENT'][$x];
$sub_total+=$ia[$x];
$weight=$_POST['WEIGHT'];
$ship_met=$_POST['SHIPPING_METHOD'];
$ship_p=shipfee($weight,$ship_met);
$total=$sub_total+$ship_p;
totalFee($sub_total,$ship_p);
$total_service_fee=totalFee($sub_total,$ship_p);
$total_all_rmb=totalFeeRMB($sub_total,$ship_p);
$sql =
"INSERT INTO `calculation`.`fee calculation`
(`URL`, `Product Price
(RMB)`, `Amount`, `Delivery Price (RMB)`, `Item Amount (RMB)`, `Sub
Total(RMB)`, `Estimate Weight`,`Shipping Method`,`Shipping Price`, `Total
Amount(RMB)`, `total amount with service fee`, `Final Total Amount
(RM)`,`memo`)
VALUES
('$url[$x]',$p[$x],$num[$x],$dp[$x],$ia[$x],$sub_total,$weight,'$ship_met'
,$ship_p,$total,$total_service_fee,$total_all_rmb,'$comment[$x]');";
$result=mysql_query($sql);
if(!$result)
{
die("Could not insert the database:<br/>".mysql_error());
}
echo "URL: "."$url[$x]<br/>";
echo "PRICE: "."$p[$x]<br/>";
echo "AMOUNT: "."$num[$x]<br/>";
echo "Delivery Price: "."$dp[$x]<br/>";
echo "Item Amount: "."$ia[$x]<br/>";
echo "Comment: "."$comment[$x]<br/>";
echo "Sub_Total: "."$sub_total<br/>";
echo "Weight: "."$weight<br/>";
echo "Shipping Method: "."$ship_met<br/>";
echo "Shipping Price: "."$ship_p<br/>";
echo "Total Amount: "."$total<br/>";
echo "Total Amount with service fee: "."$total_service_fee<br/>";
echo "Total All in RMB: "."$total_all_rmb<br/><br/><br/>";
}
mysql_close($connection);
?>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.111.167.144
※ 編輯: junzuo 來自: 218.111.167.144 (12/15 18:23)
→
12/15 23:32, , 1F
12/15 23:32, 1F
→
12/16 07:36, , 2F
12/16 07:36, 2F
→
12/16 09:12, , 3F
12/16 09:12, 3F
推
12/16 16:58, , 4F
12/16 16:58, 4F
→
12/16 18:12, , 5F
12/16 18:12, 5F
→
12/16 20:18, , 6F
12/16 20:18, 6F
推
12/17 00:25, , 7F
12/17 00:25, 7F
→
12/17 15:18, , 8F
12/17 15:18, 8F
→
12/17 15:18, , 9F
12/17 15:18, 9F
推
12/18 00:41, , 10F
12/18 00:41, 10F