mysqli_query,mysqli_fetch_array和while循环 [英] mysqli_query, mysqli_fetch_array and while loop
问题描述
我是PHP的新手,我正在尝试使用PHP建立一个网站.我有用于测试结果的本地主机,并且已经在网站上安装了phpmyadmin.
I am new to PHP and I am trying to build a website using PHP. I have localhost for testing the result and I have phpmyadmin already installed on the website.
我现在要做的是从数据库门户"中列出我的表属性"的内容,并用结果填充表.
What i am trying to do now, is to list the contents of my table "property" from database "portal" and fill a table with the results.
我正在使用mysqli_query
,mysqli_fetch_array
和while循环.我收到以下错误:
I am using mysqli_query
, mysqli_fetch_array
and while loop. I'm getting the following error:
警告:mysqli_fetch_array()期望参数1为mysqli_result, 在C:\ xampp \ htdocs \ falcon \ portal \ forms \ edit listing.php中给出的布尔值 在第15行
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\falcon\portal\forms\edit 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>';
推荐答案
以此替换您的查询.确保您之前已添加此行.
Replace your query with this. Make sure you have added this line before.
$db = mysql_select_db('portal');
$sqlCommand = "SELECT * FROM property";
这篇关于mysqli_query,mysqli_fetch_array和while循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!