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[name] x $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.
|