php - 在正确位置的 roomlist() 中显示 activechatusers()
问题描述
我正在编写一些爱好 PHP 聊天室项目,但我卡住了,在房间列表中的正确位置显示活动的房间用户列表。用户列表应该显示在某个表内的文本流中,但是当我尝试通过 PHP 中的函数调用将其显示在想要的位置时,PHP 会忽略该位置并在显示 while() 之前或之后显示预格式化的 SQL 输出。 .
我怎样才能在另一个while()中显示这个while(),或者至少是它想要的Textoutput?
这是我的代码:
while($c >0){
echo '<table style="border-collapse: collapse; width: 100%;" border="1">
<tbody>
<tr>
<td style="width: 100%;"><RoomHeading>'.$Roomname[$c].'</RoomHeading></td>
</tr>
</tbody>
</table>
<table style="border-collapse: collapse; width: 100%;" border="1">
<tbody>
<tr>
<td style="width: 50%;"><img src="Bild.jpg"></td>
<td style="width: 50%;"><div id="Roomlisttext"><Roomtext>'.$Roomthema[$c].' '.listusers_horizontal($Roomname[$c]).'</Roomtext><br></div></td>
</tr>
</tbody>
</table>
<table style="border-collapse: collapse; width: 100%;" border="1">
<tbody>
<tr>
<td style="width: 100%;"><a class="floatr" href="core.php?changeroom='.$Roomname[$c].'">Betreten</a></td>
</tr>
</tbody>
</table>
';
$c--;
}
如您所见,我想在正确的位置显示 listusers_horizontal() 的输出,在我的表内,为我的 Chatroomlist 中的每个打开的房间
这是 listusers_horizontal() 函数的代码:
<?php
function listusers_horizontal($where){
include("db.php");
$active = $_SESSION["activeroom"];
$getActlist = "SELECT * FROM `chatlogin` WHERE Room='$where';";
$getList = mysqli_query($db, $getActlist);
if($getList){
while($row = mysqli_fetch_object($getList))
{
echo $row->User;echo " ";
}
}
else{
echo "Datenbankproblem!";
}
}
?>
当我打开页面时,php 将 While() 执行到当前行的末尾并忽略该函数调用,直到该 while() 行的末尾并将其显示在它之后.. 作为它下面的独立 HTML 块
我该怎么做才能让这个 sql 查询输出在确切的位置,它应该在哪里?
解决方案
推荐阅读
- python - 为什么当我使用 conda 安装环境时,它没有给我最新版本
- javascript - 使用扩展语法的数组的副本修改了复制的数组,怎么会?
- html - 电子邮件/时事通讯不参加 CSS 课程
- ember.js - 如何在 Ember Handlebar 中将字符串解析为 JSON
- mysql - 带有链接表和排序的 SQL 分页查询
- php - 子类模型的 Laravel 模型绑定
- html - 两个浮点数:左 div 占据非指定高度的父级的全高
- tfs - objidl.idl 的 MSBuild Windows 工具包 10 错误
- javascript - chartjs-plugin-dragdata 不适用于散点图
- php - 与 HTML 表单相关的条件 PHP 语句