我尝试使用以下代码显示数据库中的记录:
<?php
include("carconnect.php");
$sqlGet ="SELECT * FROM cars";
$sqlData = mysqli_query($connect , $sqlGet) or die ("Error retrieving data!");
while ($row = mysqli_fetch_array($sqlData , MYSQLI_ASSOC)) {
echo $row['car'];
}
?>
基本上我在网页上的所有内容都是错误检索数据信息..
更新:语音标记不应该抱歉。
答案 0 :(得分:0)
"
之前的$sqlData = "mysqli_query
中有mysqli_query
。请删除它或尝试以下代码。
尝试
include("carconnect.php");
$sqlGet ="SELECT * FROM cars";
$sqlData = mysqli_query($connect , $sqlGet) or die ("Error retrieving data!");
while ($row = mysqli_fetch_array($sqlData , MYSQLI_ASSOC)) {
echo $row['car'];
}
答案 1 :(得分:0)
使用另一种简单易用的方法:
<?php
$host='hostname';
$dbuser='dbusername';
$dbpass='pass';
$dbname='databasename';
$conn= new mysqli('$hostname','$dbuser','$dbpass','$dbname');
$sqlGet ="SELECT * FROM cars";
$result=$conn->query('$sqlget');
while($sqlData= $result->fetch_assoc())
{
echo $row['car'];
}
?>
答案 2 :(得分:0)
试试这个:
include("carconnect.php");
$sqlGet ="SELECT * FROM cars";
$sqlData = mysqli_query($connect , $sqlGet) or die ("Error retrieving data!");
$row = mysqli_fetch_array($sqlData , MYSQLI_NUM);
foreach ($row as $value) {
echo $value;
}