Hi
I added one more php page to my forum. This page shows some members data from other database on same machine. I got the output on page.
I fatched three details from database and assignedit to array variable using while loop
But it prints only last value from array variable.
My page
forum.inseever.in .
I dont want to use any plugins.
Please help me out.
Thanks in advance
Not really a lot we can do here without seeing the code you've used.
Here is the code.
I created banlist.php and placed it in root
banist.php
<?php
define('IN_MYBB', 1); require "./global.php";
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT player_nick, admin_nick, ban_reason FROM acs";
$result = $conn->query($sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
$ban= array("pn"=>htmlspecialchars($row["player_nick"]), "reason"=>htmlspecialchars($row["ban_reason"]),"admin"=>htmlspecialchars($row["admin_nick"]));
$alt_bg = alt_trow();
}
} else {
echo "0 results";
}
$conn->close();
eval("\$banlist = \"".$templates->get("banlist")."\";");
output_page($banlist);
created templates.
lime="tcat" width="10%" align="center"><span class="smalltext"><strong>Admin</strong></span></td>
<td cl
<tr>
<td class="{$alt_bg}">{$ban['pn']}<br />
<td class="{$alt_bg}" align="center">{$ban['pn']}</td>
<td class="{$alt_bg}" align="center">{$ban['reason']}</td>
<td class="{$alt_bg}" align="center">{$ban['admin']}</td>
<td class="{$alt_bg}" align="center">{$ban['admin']}</td>
</tr>
Thanks please help
It's because you're just re-setting the value of $ban every time in your loop. This should build up a string where you add a new row to the variable on every iteration. Currently, it'll only show the last result from the query.
Can you please tell what i should do. I mean how to store all info in one array and use it?
Try just changing:
eval("\$ban = \"".$templates->get("banlist_player")."\";");
to:
eval("\$ban .= \"".$templates->get("banlist_player")."\";");
I missed you already had a separate template so you just need to concatenate the results of each time you eval the banlist_player template.
I had tried it but no result. Instead when i add . It displays "Array" on page.
I think i shoud send everything in one are at a time instead of sending it in loop?
You can see the result on page. I will keep it with " ."
Oh, it might also be because you're using the variable '$ban' twice, once for the array of data and one for the name of the variable with the HTML, rename one of them.
(2016-07-21, 12:57 PM)Matt. Wrote: [ -> ]Oh, it might also be because you're using the variable '$ban' twice, once for the array of data and one for the name of the variable with the HTML, rename one of them.
Sorry I dint get. You have the code up can you please what and where exactly to change?
If I change "{$ban}" in template then it stops working
Hi got it Love you matt its working now
How can i split the pages? like 30 entries on one page
You can use LIMIT.
$sql = "SELECT player_nick, admin_nick, ban_reason FROM acs__bans LIMIT 30