<?php
$queryuser = "SELECT id, email, firstname, lastname, address, city, country FROM users WHERE role = 'client'";
$resultuser = $connection->query($queryuser);
if ($resultuser->num_rows > 0)
{
// output data of each row
while ($rowuser = $resultuser->fetch_assoc())
{
$id_user = $rowuser['id'];
$firstname = $rowuser['firstname'];
$lasttname = $rowuser['lastname'];
$email = $rowuser['email'];
$phone = $rowuser['phone'];
$city = $rowuser['city'];
$state = $rowuser['state'];
$address = $rowuser['address'];
?>
答案 0 :(得分:0)
也许您已经从此页面https://www.w3schools.com/php/php_mysql_select.asp复制了代码
$connection
变量(可能是出于安全考虑的故意方法)。num_rows
获取$resultuser
属性,但是在此查询中$resultuser
不是对象,因为查询的任何错误/错误,因为查询()失败时返回FALSE,成功则返回对象。