Alright, so my display code is bunked somehow. Everything shows until right after the table headers are set. I checked the array via print_r and everything looks legit. It counts the entries correctly, so I'm not sure what the issue is.
PHP Code:
<?php
/*======================================================================*\
|| #################################################################### ||
|| # ACTIVITY POINTS LOG BY DRMATH
|| #################################################################### ||
\*======================================================================*/
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array('style');
$specialtemplates = array('products');
// ########################## REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/adminfunctions_template.php');
// ########################## USERNAME FUNCTION ###########################
function get_username($userid) {
$sql = "SELECT username FROM " . TABLE_PREFIX . "user WHERE userid = $userid";
$result = $db->query_read_slave($sql);
$username = mysql_result($result,0);
return $username;
}
// ######################## CHECK ADMIN PERMISSIONS #######################
if (!can_administer('canadminusers'))
{
print_cp_no_permission();
}
// ######################## GET PAGE START ################################
$page = filter_input(INPUT_GET,'page',FILTER_SANITIZE_NUMBER_INT);
print_cp_header();
echo "<div class='pagetitle'>In Game Activity Points Log</div>";
// Get Points Logged //
$sql = "SELECT logid, staffid, type, points, userids, date FROM " . TABLE_PREFIX . "igpointslog";
$result = $db->query_read_slave($sql);
$logs = array();
while ( $a = mysql_fetch_array($result, MYSQL_NUM) ) {
$logs[] = $a;
}
mysql_free_result($result);
// Page Variables
if (($page == null) OR ($page == 1)) {$i = 0; $page = 1;} else {$i = (($page - 1) * 15);}
$totallogs = count($logs);
$maxpages = ceil($totallogs / 15);
$prevpage = $page - 1;
$nextpage = $page + 1;
////////////////////// Begin Log
echo "<br/><br/>";
echo "<table cellpadding='4' cellspacing='0' border='0' align='center' width='90%' style='border-collapse:separate' class='tborder' id='cpform_table'>
<tbody>
<tr valign='top'>
<td class='thead' colspan='6' align='right'> <a href='pointslog.php?'>[Restart]</a> </td>
</tr>
<tr>
<td class='tcat' align='center' colspan='6'>
<b>In-Game Points Log Viewer (page $page/$maxpages) | There are $totallogs total log entries.</b>
</td>
</tr>
<tr>
<td class='thead' align='left'>Log ID</td>
<td class='thead'>Staff Username</td>
<td class='thead'>Date</td>
<td class='thead'>Action</td>
<td class='thead'>Points</td>
<td class='thead'>User(s)</td>
</tr>";
////////////////////// Fill out 15 entries
foreach ($logs as &$l) {
if ($i < ($page * 15) ) {
// Set Variables
$logid = $l[0];
$staff = "<a href='user.php?do=edit&u=$l[1]'><b>" . get_username($l[1]) . "</b></a>";
if ($l[2] = "add") { $type = "Added Points"; } elseif ($l[2] = "edit") { $type = "Edited Points"; }
$points = $l[3];
$uarray = unserialize($l[4]);
$users = "";
foreach ($uarray as $u) {
$users .= " <a href='user.php?do=edit&u=$u'>" . get_username($u) . "</a>,";
}
$users = rtrim(trim($users), ",");
//$date = new DateTime;//
$date = $l[5];
// Get Odd or Even Row
if (($i % 2) == 1) { $class = "alt1"; } else { $class = "alt2"; }
echo "<tr valign='top'>
<td class='$class'>$logid</td>
<td class='$class'>$staff</td>
<td class='$class'>$date</td>
<td class='$class'>$type</td>
<td class='$class'>$points</td>
<td class='$class'>$users</td>
</tr>";
$i++;
}
}
////////////////////// End Log, Page-nation
echo " <tr>
<td class='tfoot' colspan='6' align='center'>";
if ($prevpage > 1) { echo " <input type='button' class='button' value='? First Page' tabindex='1' onclick='window.location='pointslog.php?page=1'> "; }
if ($page > 1) { echo " <input type='button' class='button' value='< Previous Page' tabindex='1' onclick='window.location='pointslog.php?page=$prevpage'> "; }
if ($page < $maxpages) { echo " <input type='button' class='button' value='Next Page >' tabindex='1' onclick='window.location='pointslog.php?page=$nextpage'> "; }
if ($nextpage < $maxpages) { echo " <input type='button' class='button' value='Last Page ?' tabindex='1' onclick='window.location='pointslog.php?page=$maxpages'>"; }
echo " </td>
</tr>
</tbody>
</table>";
print_cp_footer();
?>
After some tinkering, the code stops working at the line:
PHP Code:
$staff = "<a href='user.php?do=edit&u=$l[1]'><b>" . get_username($l[1]) . "</b></a>";
I think the issue is with my function. NetBeans is telling me $db isn't defined, so my guess is this is the issue.
Fixed. The function wasn't working so I changed this bit up:
PHP Code:
$staff = "<a href='user.php?do=edit&u=$l[1]'><b>" . fetch_userinfo($l[1])['username'] . "</b></a>";
if ($l[2] == "add") { $type = "Added Points"; } elseif ($l[2] == "edit") { $type = "Edited Points"; }
$points = $l[3];
$uarray = unserialize($l[4]);
$users = "";
foreach ($uarray as $u) {
// get_username($u) //
$users .= " <a href='user.php?do=edit&u=$u'>" . fetch_userinfo($u)['username'] . "</a>,";
}