Sono nuovo di PHP e sto provando a creare un sito Web utilizzando PHP. Ho localhost per testare il risultato e ho phpmyadmin già installato sul sito.mysqli_query, mysqli_fetch_array e while loop
Quello che sto cercando di fare ora, è quello di elencare il contenuto della mia tabella "proprietà" dal database "portale" e riempire una tabella con i risultati.
Sto usando mysqli_query
, mysqli_fetch_array
e mentre ciclo. Sto ottenendo il seguente errore:
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>';
Grazie. L'errore è scomparso ma non visualizzo alcun dato. – Omar
Buono. Dopo la query, digita immediatamente questa riga e controlla quante righe ottieni. echo $ totalRows = mysql_num_rows ($ query); –
Anche dopo parentesi non hai parentesi graffe ($ row = mysqli_fetch_array ($ query)). Dovrebbe essere while ($ row = mysqli_fetch_array ($ query)) {e quindi terminarlo dopo il tag table, '; } –