我想将 foreach 转换为 if 语句,因为 mysql 查询只返回一行。所以我想使用 if 而不是 foreach
$db = new db();
$db -> serverconnection();
$item = $_GET["name"];
$query = "SELECT c.firstname,c.phonenumber,c.address FROM `order` o,customerdetails c WHERE o.ordercode = '$item' AND c.sno=o.customerid";
$results = $db->selectQuery($query);
foreach ($results as $customerdetails)
{
$orderidDetail = $customerdetails['customerid'];
echo $customerdetails["firstname"];
echo $customerdetails["phonenumber"];
echo $customerdetails["address"];
}