设置查询变量的值

时间:2018-02-23 01:43:20

标签: php variables

任何人都知道如何获得TID。我只需要TID并将其设置为变量$TID

$sql = 'SELECT TID FROM  walkin ORDER BY TID DESC LIMIT 1';

$result = mysqli_query($conn, $sql);

if ($conn->error) {
    die("Query failed: " . $conn->error);
}
$TID = /answer here/

1 个答案:

答案 0 :(得分:0)

使用bind_resultfetch来电的预备声明怎么样?

if($stmt=$conn->prepare("SELECT TID FROM walkin ORDER BY TID DESC LIMIT 1")){
    if($stmt->execute() && $stmt->bind_result($TID) && $stmt->fetch()){
        echo $TID;
    }
}