加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – mysqli_query,mysqli_fetch_array和while循环

发布时间:2020-12-13 14:08:19 所属栏目:PHP教程 来源:网络整理
导读:我是 PHP的新手,我正在尝试使用 PHP构建一个网站.我有localhost用于测试结果,我已经在网站上安装了phpmyadmin. 我现在要做的是从数据库“portal”列出我的表“property”的内容,并用结果填充表格. 我正在使用mysqli_query,mysqli_fetch_array和while循环.我
我是 PHP的新手,我正在尝试使用 PHP构建一个网站.我有localhost用于测试结果,我已经在网站上安装了phpmyadmin.

我现在要做的是从数据库“portal”列出我的表“property”的内容,并用结果填充表格.

我正在使用mysqli_query,mysqli_fetch_array和while循环.我收到以下错误:

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result,
boolean given in C:xampphtdocsfalconportalformsedit listing.php
on line 15

session_start();
require_once "connect_to_mysql.php"; // where i store username and password to access    my db.

$sqlCommand = "SELECT * property FROM portal"; // dbname: portal - table: propery
$query = mysqli_query($myConnection,$sqlCommand);

$Displayproperty = '';
while ($row = mysqli_fetch_array($query))
$id = $row["pid"];
$title = $row["ptitle"];
$area = $row["parea"];
$city = $row["pcity"];
$Displayproperty .= '<table width="500" border="0" cellspacing="0" cellpadding="1">
<tr>
<td>' . $id . '</td>
<td>' . $title . '</td>
<td>' . $area . '</td>
<td>' . $city . '</td>
<td><a href="forms.php?pid=' . $id . '">Upload images</a><br /></td>
</tr>
</table>';
用此替换您的查询.确保之前已添加此行.
$db = mysql_select_db('portal');

$sqlCommand = "SELECT * FROM property";

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读