Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-12-2008, 06:01 AM
meenstreek meenstreek is offline
 
Join Date: Jun 2007
Location: Sydney, Australia
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need Help With custom vBPage

Greetings,

I am making a Guild Bank system and right now I'm trying get the data I have stored in a database and display a report. I'm having trouble with using eval() to push out information to a template. Only it's a template within a template whitin a template. Basically this is what I have for templates:
gb_tranman_historyshell
gb_tranman_historybits
gb_tranman_resourcebits

Now I'm using gb_tranman_historyshell to call gb_tranman_historybits to call gb_tranman_resourcebits.

My code looks like this:
PHP Code:
  if ($_GET['userid'] != NULL) {
    
$uid $_REQUEST['userid'];
    
$uid intval($uid);
    
$q $db->query_read("SELECT user.userid, user.username, resourcetransactions.* 
        FROM user
    LEFT JOIN resourcetransactions ON resourcetransactions.userid = 
$uid
    WHERE user.userid = 
$uid");    
    
$q2 $db->query_read("SELECT username from user where userid = $uid");
    
$q4 $db->query_read("SELECT transactionid FROM resourcetransactions WHERE userid = $uid");
        
    
//Historybits For Member
    
while($historybits $db->fetch_array($q)){
        
$trans $historybits[transactionid];
    
$trans intval($trans);
        
$q3 $db->query_read("SELECT resources.name, resctotrans.qty
        FROM resources
        LEFT JOIN resctotrans ON resctotrans.transactionid = 
$trans
        WHERE resources.resourcesid = resctotrans.resourceid"
);
        
//Resourcebits For Member
    
while($resource $db->fetch_array($q3)){
              eval(
'$resourcebits .= "' fetch_template('gb_tranman_resourcebits') . '";');
    }
    eval(
'$history .= "' fetch_template('gb_tranman_historybits') . '";');    
    }
    
//History Shell
    
$user $db->fetch_array($q2);
        eval(
'$historyshell = "' fetch_template('gb_tranman_historyshell') . '";');    
    } 
gb_tranman_historyshell looks like this:
PHP Code:
<table class="tborder" cellpadding="$stylevar[cellpadding]cellspacing="$stylevar[cellspacing]border="0" width="50%" align="center">
  <
tr>
    <
td valign="top" colspan="2" class="alt1"><div align="center">Transaction History for $user[username]</div></td>
  </
tr>
  
$history
</table
gb_tranman_historybits looks like this:
PHP Code:
          <tr>
        <
td class="alt1">
          
Date$historybits[date]
          </
td>
        </
tr>
        <
tr>
          <
td class="alt1">
            
$resourcebits
          
</td>
        </
tr>
        <
tr>
          <
td class="alt1">
          
Notes:
          <
blockquote>$historybits[notes]</blockquote>
          </
td>
        </
tr
gb_tranman_resourcebits looks like this:
PHP Code:
$resource[namex $resource[qty] <br /> 
When I pass it the userid of a member it should get each transaction that member has had. And within each transaction it should show what resources & how many each transaction had. I'm guessing that I'm completely wrong here and the code is much easier.

Any suggestions?

--------------- Added [DATE]1213261820[/DATE] at [TIME]1213261820[/TIME] ---------------

Okay, I found a solution. I dropped the 3rd template (gb_tranman_resourcebits) and added replaced this code:
PHP Code:
    while($resource $db->fetch_array($q3)){
              eval(
'$resourcebits .= "' fetch_template('gb_tranman_resourcebits') . '";');
    } 
With this:
PHP Code:
    $resbits '';
    while(
$resourcebits $db->fetch_array($q3)){
        
$resbits .= "$resourcebits[name] x $resourcebits[qty]<br />";
    } 
And just added the variable $resbits in my gb_tranman_historybits. It works now .
I would however like to see how else I could code this as I'm sure it's probably not correct heh.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:10 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.08078 seconds
  • Memory Usage 2,198KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)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
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete