【发布时间】:2017-12-11 20:34:54
【问题描述】:
我的数据库中有表地址。我把 value=$Id;对于我的单选按钮,但我不知道为什么它不起作用。没有显示错误让我感到困惑,我需要帮助,因为我还是 php 新手。当我输入 2 个地址并检查单选按钮时,地址没有改变。它只取用户插入的最新的。
$userid=$_SESSION["userID"];
$sql="SELECT * FROM customer where ID='$userid'";
$result = mysqli_query( $con,$sql);
while($row = mysqli_fetch_array($result))
{
$Id=$row['Id'];
$OrderID=$row['OrderID'];
$ID=$row['ID'];
$Name=$row['Name'];
$Email=$row['Email'];
$Address=$row['Address'];
$PostalCode=$row['PostalCode'];
$City=$row['City'];
$State=$row['State'];
$mobile=$row['mobile_number'];
// $total=$total+$pSubtotal;
// $totalWeight=$totalWeight+$subWeight;
echo "<input type=\"radio\" name=\"select\" value=\"$Id\"> <label>$Name</label><br>";
echo "$Address<br>";
echo "$PostalCode $City<br>";
echo "$State";
echo "<div> </div>";
echo "<img src=\"images/phone-icon.png\" width=\"20\" height=\"20\"> $mobile<br>";
echo "<img src=\"images/email.png\" width=\"20\" height=\"20\"> $Email<br>";
echo "<div> </div>";
echo "<div class=\"col-xs-12 col-lg-12\" style=\"border-bottom:1px solid #ccc;\"></div>";
}
if(isset($_POST["pay"])){
$userid=$_SESSION["userID"];
$final_price=$_POST["final_price"];
$name=$_POST["name"];
$email=$_POST["email"];
$postcode=$_POST["postcode"];
//echo $postcode;
$mobile_number=$_POST["mobile_number"];
//echo $name;
$radio=$_POST['select'];
if(isset($radio)){
$sql="select Id,Name,mobile_number,Email,Address,PostalCode,City,State from customer where Id='$radio'";
echo $sql;
$res = mysqli_query($con,$sql);
if($rows=mysqli_fetch_array($res)){
$idx=$rows['Id'];
$name=$rows['Name'];
$mobile=$rows['mobile_number'];
$email=$rows['Email'];
$address=$rows['Address'];
$postcode=$rows['PostalCode'];
$city=$rows['City'];
$state=$rows['State'];
}
}
}
【问题讨论】:
标签: php