I am trying to get mysql data to show in a xenForo page.
This is my original php file that I want to show on the page:
So I made a new page in xenForo and made a callback php
and a banlist template
I am not to sure how to get the row data into the template from the while loop.
This is my original php file that I want to show on the page:
Code:
<?php
// change these things
$server = "localhost";
$dbuser = "xxxxxxx";
$dbpass = "xxxxxxxx";
$dbname = "xxxxxxxx";
mysql_connect($server, $dbuser, $dbpass);
mysql_select_db($dbname);
$result = mysql_query("SELECT * FROM banlist ORDER BY time DESC");
echo "<table width=70% border=1 cellpadding=5 cellspacing=0>";
echo "<tr style=\"font-weight:bold\">
<td>Name</td>
<td>Reason</td>
<td>Admin/Mod</td>
<td>Time of ban</td>
<td>Time of unban</td>
</tr>";
while($row = mysql_fetch_assoc($result)){
if($col == "#eeeeee"){
$col = "#ffffff";
}else{
$col = "#eeeeee";
}
echo "<tr bgcolor=$col>";
echo "<td>".$row['name']."</td>";
echo "<td>".$row['reason']."</td>";
echo "<td>".$row['admin']."</td>";
echo "<td>".$row['time']."</td>";
if($row['temptime'] == "0000-00-00 00:00:00"){
echo "<td>Permanent</td>";
}else{
echo "<td>".$row['temptime']."</td>";
}
echo "</tr>";
}
echo"</table>"
?>
So I made a new page in xenForo and made a callback php
Code:
<?php
class CallBack_Bans
{
public static function respond(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract $response)
{
$server = "localhost";
$dbuser = "xxxxx";
$dbpass = "xxxxxx";
$dbname = "xxxxx";
mysql_connect($server, $dbuser, $dbpass);
mysql_select_db($dbname);
$result = mysql_query("SELECT * FROM banlist ORDER BY time DESC");
while($row = mysql_fetch_assoc($result)){
//send row data to template
}
$response->templateName = 'banlist';
}
}
and a banlist template
Code:
<xen:title>{$page.title}</xen:title>
<div class="sectionMain">
<h2 class = "subHeading">Ban List</h2>
<table width=70% border=1 cellpadding=5 cellspacing=0>
<tr style=\"font-weight:bold\">
<td>Name</td>
<td>Reason</td>
<td>Admin/Mod</td>
<td>Time of ban</td>
<td>Time of unban</td>
</tr>
</table>
</div>
I am not to sure how to get the row data into the template from the while loop.