我正在使用SELECT * FROM "" WHERE "" = ""
查询,而且我不确定我做错了什么。我试图根据其PO选择一个项目,这是表格中一行的完全唯一标识符。这是我这样做的过程:
$jobnumber = $_GET['jref'];
$query = "SELECT * FROM `po_10152796` WHERE `po` = " .$jobnumber;
$results = mysqli_query($conn,$query) or die(mysqli_error($conn));
$rowitem = mysqli_fetch_array($results);
$jobname = $rowitem['Job Name'];
$phone = $rowitem['phone'];
我知道的事情是正确的:
答案 0 :(得分:1)
忘了发布这个,用准备好的语句重新编写代码并且它有效,不知道我究竟改变了什么,但无论如何它在这里:
$jobnumber = $_GET['jref'];
$stmt = $conn->prepare( "SELECT `Job Name`, `Address`, `phone`, `description`, `materials` FROM po_10152796 WHERE po = ?");
$stmt->bind_param("i", $jobnumber);
if($stmt->execute()){
$stmt->bind_result($jobname, $address, $phone, $description, $materials);
$stmt->fetch();
}
答案 1 :(得分:-2)
为查询尝试此行
$query = "SELECT * FROM `po_10152796` WHERE `po` = '" .$jobnumber. "' ";