I'm writing some Hobby PHP Chatroom Project and i got stuck, displaying the active Rooms userlist at the correct position within the roomslist. The userlist should be displayed within the textflow inside some Table, but when i try to display it at the wanted position via function call in PHP, PHP ignores the Position and displays the preformatted SQL Output either before the displaying while() or after it..
How can i Display this while() in the other while() where it should be, or at Least the wanted Textoutput of it?
Here is my Code:
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--;
}
As you should see, i want to display the output of listusers_horizontal() at the right Position, inside my Table for each open Room in my Chatroomlist
Here is the Code of the listusers_horizontal() function:
<?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!";
}
}
?>
When i open the page, php executes the While() to the end of the current row and ignores that function call until the end of that while() row and displays it after it.. as standalone HTML Block under it
What can i do to get this sql Query output at the exact position, where it should be?