我想问一下如何在HTML表格中显示来自php类的数据我尝试用HTML标签回显主题但由于某些原因我的代码无法识别html标签。
public function getDataUser()
{
$sql = "SELECT ID, USERNAME , PASSWORD , EMAIL , PERMISSION_LEVEL FROM USERS";
$this->_data = $this->_connection->query($sql);
while ($row = $this->_data->fetch_assoc()) {
echo $row["ID"] .$row["USERNAME"] . $row["PASSWORD"]. $row["EMAIL"] . $row["PERMISSION_LEVEL"];
echo"<br />";
}
return $this->_data;
}
此br标签不起作用。
答案 0 :(得分:0)
当您返回数据时,您可能只想测试收到的数据: 那么你可以使用print_r(在&lt; pre&gt;标签之间):
public function getDataUser()
{
$sql = "SELECT ID, USERNAME , PASSWORD , EMAIL , PERMISSION_LEVEL FROM USERS";
$this->_data = $this->_connection->query($sql);
while ($row = $this->_data->fetch_assoc()) {
echo "<pre>";
print_r($row);
echo "</pre>";
}
return $this->_data;
}
答案 1 :(得分:0)
试试这个
public function getDataUser()
{
$sql = "SELECT ID,USERNAME,PASSWORD,EMAIL,PERMISSION_LEVEL FROM USERS";
$this->_data = $this->_connection->query($sql);
while ($row = $this->_data->fetch_assoc()) {
//do print_r() to check wether data is coming or not
echo '<pre>';
print_r($row);
echo '</pre>';
//or you can print directly value by $row['ID']." ".$row['USERNAME'] by this way
}
return $this->_data;
}
答案 2 :(得分:-1)
echo $row["ID"] .$row["USERNAME"] . $row["PASSWORD"]. $row["EMAIL"] . row["PERMISSION_LEVEL"]. " <br>";