我是 PHP 的新手,但这是我的问题,我试图从 SQL 查询中获取结果以显示在页面上,但我没有收到任何返回信息。
这是我目前正在使用的代码:
<?php
$con = mysqli_connect("localhost","user","password","database");
if (mysqli_connect_errno()) {
echo "Connect failed: ". mysqli_connect_error();
}
$de= $con->real_escape_string($_GET["decode"]);
$sql = "select * from FG99_URL where short='".$de."'";
$result = mysqli_query($con, $sql);
while($row = mysqli_fetch_assoc($result)) {
echo "url: " . $row["url"]. " - fb_url: " . $row["fb_url"]."<br>";
$url=$row['url'];
$fb_url=$row['fb_url'];
$fb_type=$row['fb_type'];
$fb_title=$row['fb_title'];
$fb_description=$row['fb_description'];
$fb_image=$row['fb_image'];
$petpro=$row['petpro'];
echo $fb_url.'test 1</br>';
echo $row['fb_url'] . "test 2</br>";
print $fb_url."test 3</br>";
print $row['fb_url']."test 4</br>";
}
?>
<head>...
这是我返回的内容:
url: - fb_url:
test 1
test 2
test 3
test 4
如有任何帮助,我们将不胜感激。
最佳答案
执行 var_dump($row)
并查看 row 变量中的内容。
这将有助于查看您在那些返回的数据集中是否有这些数据。
根据输出,您正在获取一些数据,但返回的数据可能没有您要查找的列。
希望对您有所帮助。
关于PHP 从 MySQL 查询返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46418431/