我知道这很麻烦,但是到了我的系绳的末端,这应该可行,但我不明白为什么我不能将我的订单表的第一个值放入变量order_id ,任何人都可以看到我的错误吗?
由于
$con = mysql_connect("localhost", "tim", "password");
if (!$con) {
die('Could not connect: '.mysql_error());
}
$sql = "SELECT TOP 1 order_order_id FROM tbl_order ORDER BY order_id DESC";
$result = mysql_query($sql, $con);
while ($rows = mysql_fetch_array($result)) {
$order_id = $rows;
}
答案 0 :(得分:-1)
使用此代码并告诉我它是否有效:
$con = mysql_connect("localhost","tim","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$sql = "SELECT TOP 1 order_order_id FROM tbl_order ORDER BY order_id DESC";
$result = mysql_query($sql,$con);
if (mysql_num_rows($result)) {
$rows = mysql_fetch_assoc($result);
$order_id = $rows['order_order_id'];
} else {
die('No order ID found');
}