View Single Post
  #15  
Old 11-14-2014, 07:23 PM
KGodel's Avatar
KGodel KGodel is offline
 
Join Date: May 2011
Location: Indiana
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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($resultMYSQL_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'> &nbsp; "; }
if (
$page 1) { echo "      <input type='button' class='button' value='< Previous Page' tabindex='1' onclick='window.location='pointslog.php?page=$prevpage'> &nbsp; "; }
if (
$page $maxpages) { echo "      <input type='button' class='button' value='Next Page >' tabindex='1' onclick='window.location='pointslog.php?page=$nextpage'> &nbsp; "; }
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>,";
        } 
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01872 seconds
  • Memory Usage 1,865KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete