我有两个单选按钮,每个按钮都有表名的值。
<input type="radio" name="method" value="tableOne"/>
<input type="radio" name="method" value="tableTwo"/>
<?php
$table=$_POST['method'];
insert into $table (blabblalalbalblabal.........)...
?>
但它似乎无法发挥作用。
请问好吗?
答案 0 :(得分:1)
我建议您使用IF
确定插入语句。
<?php
$deliveryMethod = $_POST['deliveryMethod'];
if('InfiStallStock' == $deliveryMethod){
mysql_query("INSERT INTO tbl_InfiStallStock (tableOneFieldA, tableOneFieldB, tableOneFieldC) VALUES('$member_oneremail', '$infistallLocation', '$delivery_city')");
}elseif('DeliveryStock' == $deliveryMethod){
mysql_query("INSERT INTO tbl_DeliveryStock (tableTwoFieldX, tableTwoFieldY, tableTwoFieldZ) VALUES('$member_oneremail', '$delivery_address', '$deliveryService')");
}
?>