vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Need Help With custom vBPage (https://vborg.vbsupport.ru/showthread.php?t=182255)

meenstreek 06-12-2008 06:01 AM

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.


All times are GMT. The time now is 02:04 PM.

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.00957 seconds
  • Memory Usage 1,745KB
  • 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
  • (6)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)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