[英]Retrieve specific row from database and display all the data in the specific row and send json using php
[英]cant display specific row from database using PHP though no errors is shown
当我单击 go 到表单时,我想查看有关该 ID 号的所有其他信息。 这是 go 后面的代码到表单选项:
<td width="174" class="centertext"><a href="form.php?formid=<?php echo $row["formid"]; ?>"> Go to the form</a></td>
这是我用来从数据库中检索特定行的代码。 该代码没有显示任何错误,但也没有显示结果。 我看到的只是空白页。 这里有什么问题? 我一直在尝试解决 1 周,但找不到任何东西。 我是 PHP 的初学者。 提前致谢。
<?php
$conn = mysqli_connect("localhost","root","","son_fbe");
if (mysqli_connect_error()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
}
$formid = isset($_GET['formid ']) ? $_GET['formid '] : '';
if($sql= "SELECT formid,gonderilen,gonderen FROM derssaydirma WHERE formid = ?")
{
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $formid);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
echo $row[ 'formid'];
echo $row['gonderilen'];
echo $row['gonderen']; }
$stmt->close();
}
// show an error if the query has an error
else
{
echo "Error: could not prepare SQL statement";
}
?>
我想我发现了错误..在访问 get 数组时,您的名字中有一个空白。 $formid
将是 "" 这就是您的查询不起作用的原因。
改变这一行..
$formid = isset($_GET['formid ']) ? $_GET['formid '] : '';
至
$formid = isset($_GET['formid']) ? $_GET['formid'] : '';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.