PHP从数据库获取数据并希望在<p> </p>中显示

时间:2014-08-30 08:25:41

标签: php

$customernumber = mysqli_query($dbconnect,"SELECT CustomerNumber FROM Registration WHERE Name='$name'" );

if (!mysqli_query($dbconnect, $sql)) {
die('Error: '. mysqli_error($dbconnect));
}
echo "<p>Dear $name, you are successfully registered into ShipOnline, and your customer number is $customernumber, which will be used to get into the system.</p>";

mysqli_close($dbconnect);

客户编号未显示,我该如何解决此问题?

感谢

1 个答案:

答案 0 :(得分:1)

您需要使用fetch来检索DB的记录。试试如下

$customernumber = mysqli_query($dbconnect,"SELECT CustomerNumber as cus_no FROM Registration WHERE Name='$name'" );
if (!mysqli_query($dbconnect, $sql)) {
    die('Error: '. mysqli_error($dbconnect));
}
while($row = mysqli_fetch_assoc($customernumber)) {
    $customer_number = $row['cus_no'];
}
echo "<p>Dear $name, you are successfully registered into ShipOnline, and your customer number is $customer_number, which will be used to get into the system.</p>";
mysqli_close($dbconnect);