vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   what am i doing wrong with this code? (https://vborg.vbsupport.ru/showthread.php?t=72998)

Guy G 12-17-2004 01:48 PM

what am i doing wrong with this code?
 
PHP Code:

<?php 

// ### COLLAPSABLE ENABLING ######################################## 
 
$collapseobj_toposters $vbcollapse['collapseobj_toprep'];
$collapseimg_toposters $vbcollapse['collapseimg_toprep'];


$top_stats = array(); 
// TOP REPUTATIONists 
$top_rep $DB_site->query("SELECT * FROM ".TABLE_PREFIX."user ORDER BY reputation DESC LIMIT 10"); 
while(
$top_rep $DB_site->fetch_array($top_rep)) 
unset(
$top_rep); 
$DB_site->free_result($top_rep);

eval(
'$top_stats[\'top_rep\'] .= "' fetch_template('toprep') . '";');

eval(
'$home[$mods[\'modid\']][\'content\'] = "' fetch_template('adv_portal_toprep') . '";'); 
?>

these are my templates:

toprep
PHP Code:

<li><span class="smallfont"><a href="member.php?u=$toprep[userid]">$toprep[username]</a> ($toprep[reputation])</span></li

adv_portal_toprep
PHP Code:

<table align="center" border="0" cellpadding="$stylevar[cellpadding]cellspacing="$stylevar[cellspacing]class="tborder"width="180px">
<
thead>
              <
tr
                      <
td class="tcat">
<
a style="float:$stylevar[right]href="#top" onclick="return toggle_collapse('toprep')"><img id="collapseimg_toprep" src="$stylevar[imgdir_button]/collapse_tcat$collapseimg_toprep.gif" alt="" border="0" /></a>

<
span class="smallfont"><b>$vboptions[blockbullet]<a href="$vboptions[bburl]/profile.php?$session[sessionurl]do=editlist"Top Reputations</a></b></span></td>
              </
tr>
              </
thead>
<
tbody id="collapseobj_toprep" style="$collapseobj_toprep">
              <
tr class="alt1"
                      <
td width="100%"><span class="smallfont">
$top_stats[top_rep]
                      </
td>
              </
tr>
</
tbody>
            </
table>
<
br /> 

suppose to show top 10 users with the most reputation... but doesnt for some reason..

WetWired 12-17-2004 05:31 PM

Well, your first problem is that you destroy all the data before you try to display it.
Try replacing
Code:

$top_rep = $DB_site->query("SELECT * FROM ".TABLE_PREFIX."user ORDER BY reputation DESC LIMIT 10");
while($top_rep = $DB_site->fetch_array($top_rep))
unset($top_rep);
$DB_site->free_result($top_rep);

eval('$top_stats[\'top_rep\'] .= "' . fetch_template('toprep') . '";');

with
Code:

$top_rep_res = $DB_site->query("SELECT * FROM ".TABLE_PREFIX."user ORDER BY reputation DESC LIMIT 10");
while($top_rep = $DB_site->fetch_array($top_rep_res))
  eval('$top_stats[\'top_rep\'] .= "' . fetch_template('toprep') . '";');
$DB_site->free_result($top_rep_res);



All times are GMT. The time now is 03:43 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01882 seconds
  • Memory Usage 1,734KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete