SavSin |
01-16-2012 06:50 AM |
The page should look like this.
http://www.xvgaming.com/games/stats/bfstats.php
And here is the (second page) using this article to create the template
http://www.xvgaming.com/bfstatsbynam...M_0:0:21788544
Here is the php file (standalone) that makes it like bfstats.php
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head> <LINK REL=StyleSheet HREF="bfstats.css" TYPE="text/css"> </head>
<body>
<div id="wrapper">
<div id="branding"> <a href="http://www.xvgaming.com/"> <img src="http://www.xvgaming.com/images/xvgaming/xvgaming_logo2.png" alt="Logo"> </a> </div>
<div id="navbar"> <ul> <li class="homeborder"><a href="http://www.xvgaming.com/">Home</a></li> <li class="selected"><a href="http://www.xvgaming.com/forum.php">Forum</a></li> <li><a href="http://shop.xvgaming.com/">Shop</a></li> </ul> </div>
<div id="lowerbranding"> </div>
<div id="container">
<div id="navlinks">
<a href="http://www.xvgaming.com"><img src="http://www.xvgaming.com/images/xvgaming/images/misc/navbit-home.png"></a> <a href="#">Stats</a> <img src="http://www.xvgaming.com/images/xvgaming/images/misc/navbit-arrow-right.png"> <a href="http://www.xvgaming.com/games/stats/bfstats.php">Battlefield</a> </div>
<div id="content"> <?php $host="localhost"; $user="wanderzo_savsin"; $password="savsin3"; $database="wanderzo_battlefield"; mysql_connect($host, $user, $password); @mysql_select_db($database) or die("Unable To select database"); $query = "SELECT * FROM XpTable WHERE (player_total_xp > 75) ORDER BY player_total_xp DESC"; $result = mysql_query($query); $num = mysql_numrows($result); mysql_close(); ?> <div id="topbar"> <div id="prevlink"> <?php $incriment = $_GET['nextpage']; $startid = $incriment + 0; $statsperpage = 15; if($startid > 0) { ?> <a class="button" href="http://www.xvgaming.com/games/stats/bfstats.php?nextpage=<?php echo $incriment-$statsperpage; ?>"> « Back </a> <?php } else { ?> <a class="button" href="#">« Back </a> <?php } ?> </div> <div id="steamform"> <form method="get" action="bfstatsbyname.php"> <label>Enter Your SteamID:</label> <input type="text" maxlength="20" name="SteamID" value="STEAM_0:1:23456789" onFocus="if(value == 'STEAM_0:1:23456789') {value=''}" onBlur="if(value=='') {value='STEAM_0:1:23456789'}"/> <button type="submit">Submit</button> <div class="spacer"></div> </form> </div> <div id="nextlink"> <?php if($startid + $statsperpage < $num) { ?> <a class="button" href="http://www.xvgaming.com/games/stats/bfstats.php?nextpage=<?php echo $incriment + $statsperpage; ?>">Next »</a> <?php } else { ?> <a class="button" href="#">Next » </a> <?php } ?> </div> <div class="spacer"></div> </div> <table class="stats"> <tr> <th class="stats">Rank</th> <th class="stats">Name</th> <th class="stats">XP</th> <th class="stats">Assault</th> <th class="stats">Special Ops</th> <th class="stats">Sniper</th> <th class="stats">Engineer</th> <th class="stats">Medic</th> <th class="stats">Support</th> </tr> <?php $i = $startid; $RankNumber = $startid + 1; while($i < $num) { $player_id=mysql_result($result, $i, "player_id"); $player_name=mysql_result($result,$i,"player_name"); $player_total_xp=mysql_result($result,$i,"player_total_xp"); $player_class_assault_xp=mysql_result($result,$i,"player_class_assault_xp"); $player_class_specops_xp=mysql_result($result,$i,"player_class_specops_xp"); $player_class_sniper_xp=mysql_result($result,$i,"player_class_sniper_xp"); $player_class_engineer_xp=mysql_result($result,$i,"player_class_engineer_xp"); $player_class_medic_xp=mysql_result($result,$i,"player_class_medic_xp"); $player_class_support_xp=mysql_result($result,$i,"player_class_support_xp"); if($i < ($startid + $statsperpage)) { ?> <tr> <td class="stats"><?php echo $RankNumber; ?></td> <td class="stats"><a href="http://www.xvgaming.com/games/stats/bfstatsbyname.php?SteamID=<?php echo $player_id; ?>&Rank=<?php echo $RankNumber; ?>"><?php echo $player_name; ?></a></td> <td class="stats"><?php echo $player_total_xp; ?></td> <td class="stats"><?php echo $player_class_assault_xp; ?></td> <td class="stats"><?php echo $player_class_specops_xp; ?></td> <td class="stats"><?php echo $player_class_sniper_xp; ?></td> <td class="stats"><?php echo $player_class_engineer_xp; ?></td> <td class="stats"><?php echo $player_class_medic_xp; ?></td> <td class="stats"><?php echo $player_class_support_xp; ?></td> </tr> <?php $i++; $RankNumber++; } else { break; } } ?> </table> </div> <div class="spacer"></div> <div id="footer"> <div id="footerprevlink"> <?php $incriment = $_GET['nextpage']; $startid = $incriment + 0; $statsperpage = 15; if($startid > 0) { ?> <a class="button" href="http://www.xvgaming.com/games/stats/bfstats.php?nextpage=<?php echo $incriment-$statsperpage; ?>"> « Back </a> <?php } else { ?> <a class="button" href="#">« Back </a> <?php } ?> </div> <div id="footernextlink"> <?php $incriment = $_GET['nextpage']; $startid = $incriment + 0; if($startid + $statsperpage < $num) { ?> <a class="button" href="http://www.xvgaming.com/games/stats/bfstats.php?nextpage=<?php echo $incriment + $statsperpage; ?>">Next »</a> <?php } else { ?> <a class="button" href="#">Next » </a> <?php } ?> </div> <div class="spacer"></div> </div>
<div class="spacer"></div> </div>
</div>
</body>
</html>
Here is a link to what it looks like when i do the stuff for the template. I think the issue is that when it loops to create the table rows. There is only one set of variables which get changed each loop. So I think i need to create seperate variables for each row(while it loops and register them all in the loop)
Atleast thats what i think is wrong with it. Here is the link and the php/template files
http://www.xvgaming.com/bfstats.php
PHP Code:
<?php
// ####################### SET PHP ENVIRONMENT ########################### error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'bfstats'); define('CSRF_PROTECTION', true); // change this depending on your filename
// ################### PRE-CACHE TEMPLATES AND DATA ###################### // get special phrase groups $phrasegroups = array();
// get special data templates from the datastore $specialtemplates = array();
// pre-cache templates used by all actions $globaltemplates = array('BfStats', );
// pre-cache templates used by specific actions $actiontemplates = array();
// ######################### REQUIRE BACK-END ############################ // if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line // chdir ('/path/to/your/forums'); require_once('./global.php');
// ####################################################################### // ######################## START MAIN SCRIPT ############################ // #######################################################################
$navbits = construct_navbits(array('' => 'Battlefield')); $navbar = render_navbar_template($navbits);
// ###### YOUR CUSTOM CODE GOES HERE ##### $pagetitle = 'Battlefield Stats';
$host="localhost"; $user="wanderzo_savsin"; $password="savsin3"; $database="wanderzo_battlefield";
mysql_connect($host, $user, $password);
@mysql_select_db($database) or die("Unable To select database");
$query = "SELECT * FROM XpTable WHERE (player_total_xp > 75) ORDER BY player_total_xp DESC";
$result = mysql_query($query);
$num = mysql_numrows($result);
mysql_close();
$incriment = $_GET['nextpage']; $startid = $incriment + 0; $statsperpage = 15;
if($startid > 0) { $prevstatspage = $incriment-$statsperpage; $prevlink = '<a class="button" href="http://www.xvgaming.com/bfstats.php?nextpage='; $prevlink2 = '"> « Back </a>'; } else { $prevlink = '<a class="button" href="http://www.xvgaming.com/bfstats.php#">« Back </a>'; } if($startid + $statsperpage < $num) { $nextstatspage = ($incriment + $statsperpage); $nextlink = '<a class="button" href="http://www.xvgaming.com/bfstats.php?nextpage='; $nextlink2 = '">Next »</a>'; } else { $nextlink = '<a class="button" href="http://www.xvgaming.com/bfstats.php#">Next » </a>'; }
$i = $startid; $RankNumber = $startid + 1;
while($i < $num) { $player_id=mysql_result($result, $i, "player_id"); $player_name=mysql_result($result,$i,"player_name"); $player_total_xp=mysql_result($result,$i,"player_total_xp"); $player_class_assault_xp=mysql_result($result,$i,"player_class_assault_xp"); $player_class_specops_xp=mysql_result($result,$i,"player_class_specops_xp"); $player_class_sniper_xp=mysql_result($result,$i,"player_class_sniper_xp"); $player_class_engineer_xp=mysql_result($result,$i,"player_class_engineer_xp"); $player_class_medic_xp=mysql_result($result,$i,"player_class_medic_xp"); $player_class_support_xp=mysql_result($result,$i,"player_class_support_xp"); if($i < ($startid + $statsperpage)) { $starttablerow = '<tr>'; $starttablecell1 = '<td class="stats">'; $endtablecell1 = '</td>'; $starttablecell2 = '<td class="stats"><a href="http://www.xvgaming.com/bfstatsbyname.php?SteamID='; $tablecell2center = '">'; $endtablecell2 = '</a></td>'; $starttablecell3 = '<td class="stats">'; $endtablecell3 = '</td>'; $starttablecell4 = '<td class="stats">'; $endtablecell4 = '</td>'; $starttablecell5 = '<td class="stats">'; $endtablecell5 = '</td>'; $starttablecell6 = '<td class="stats">'; $endtablecell6 = '</td>'; $starttablecell7 = '<td class="stats">'; $endtablecell7 = '</td>'; $starttablecell8 = '<td class="stats">'; $endtablecell8 = '</td>'; $starttablecell9 = '<td class="stats">'; $endtablecell9 = '</td>'; $endtablerow = '</tr>'; $i++; $RankNumber++; } else { break; } }
// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######
$templater = vB_Template::create('BfStats'); $templater->register_page_templates(); $templater->register('navbar', $navbar); $templater->register('pagetitle', $pagetitle);
$templater->register('prevstatspage', $prevstatspage); $templater->register('prevlink', $prevlink); $templater->register('prevlink2', $prevlink2);
$templater->register('nextstatspage', $nextstatspage); $templater->register('nextlink', $nextlink); $templater->register('nextlink2', $nextlink2);
//Rank Info $templater->register('RankNumber', $RankNumber); $templater->register('player_id', $player_id); $templater->register('player_name', $player_name); $templater->register('player_total_xp', $player_total_xp); $templater->register('player_class_assault_xp', $player_class_assault_xp); $templater->register('player_class_specops_xp', $player_class_specops_xp); $templater->register('player_class_sniper_xp', $player_class_sniper_xp); $templater->register('player_class_engineer_xp', $player_class_engineer_xp); $templater->register('player_class_medic_xp', $player_class_medic_xp); $templater->register('player_class_support_xp', $player_class_support_xp);
//Start Table $templater->register('starttablerow', $starttablerow);
//Open Table Rows $templater->register('starttablecell1', $starttablecell1); $templater->register('starttablecell2', $starttablecell2); $templater->register('starttablecell3', $starttablecell3); $templater->register('starttablecell4', $starttablecell4); $templater->register('starttablecell5', $starttablecell5); $templater->register('starttablecell6', $starttablecell6); $templater->register('starttablecell7', $starttablecell7); $templater->register('starttablecell8', $starttablecell8); $templater->register('starttablecell9', $starttablecell9);
//Cell Centers $templater->register('tablecell2center', $tablecell2center);
//End the table rows $templater->register('endtablecell1', $endtablecell1); $templater->register('endtablecell2', $endtablecell2); $templater->register('endtablecell3', $endtablecell3); $templater->register('endtablecell4', $endtablecell4); $templater->register('endtablecell5', $endtablecell5); $templater->register('endtablecell6', $endtablecell6); $templater->register('endtablecell7', $endtablecell7); $templater->register('endtablecell8', $endtablecell8); $templater->register('endtablecell9', $endtablecell9);
//End table $templater->register('endtablerow', $endtablerow);
print_output($templater->render()); ?>
Code:
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml"<vb:if condition="$vboptions['enablefacebookconnect']"> xmlns:fb="http://www.facebook.com/2008/fbml"</vb:if> dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
<LINK REL=StyleSheet HREF="games/stats/player_stats.css" TYPE="text/css">
{vb:raw headinclude}
<title>{vb:raw pagetitle}</title>
<vb:if condition="$includecss">
<vb:if condition="$vboptions['storecssasfile']">
<vb:each from="includecss" value="file">
{vb:cssfile {vb:raw file}}
</vb:each>
<vb:else />
{vb:cssfile {vb:raw includecss}}
</vb:if>
</vb:if>
{vb:raw headinclude_bottom}
</head>
<body>
{vb:raw header}
{vb:raw navbar}
<div id="content">
<div id="topbar">
<div id="prevlink">
{vb:raw prevlink}{vb:raw prevstatspage}{vb:raw prevlink2}
</div>
<div id="steamform">
<form method="get" action="http://www.xvgaming.com/bfstatsbyname.php">
<label>Enter Your SteamID:</label>
<input type="text" maxlength="20" name="SteamID" value="STEAM_0:1:23456789" onFocus="if(value == 'STEAM_0:1:23456789') {value=''}" onBlur="if(value=='') {value='STEAM_0:1:23456789'}"/>
<button type="submit">Submit</button>
<div class="spacer"></div>
</form>
</div>
<div id="nextlink">
{vb:raw nextlink}{vb:raw nextstatspage}{vb:raw nextlink2}
</div>
<div class="spacer"></div>
</div>
<table class="stats">
<tr>
<th class="stats">Rank</th>
<th class="stats">Name</th>
<th class="stats">XP</th>
<th class="stats">Assault</th>
<th class="stats">Special Ops</th>
<th class="stats">Sniper</th>
<th class="stats">Engineer</th>
<th class="stats">Medic</th>
<th class="stats">Support</th>
</tr>
{vb:raw starttablerow}
{vb:raw starttablecell1}{vb:raw RankNumber}{vb:raw endtablecell1}
{vb:raw starttablecell2}{vb:raw player_id}{vb:raw tablecell2center}{vb:raw player_name}{vb:raw endtablecell2}
{vb:raw starttablecell3}{vb:raw player_total_xp}{vb:raw endtablecell3}
{vb:raw starttablecell4}{vb:raw player_class_assault_xp}{vb:raw endtablecell4}
{vb:raw starttablecell5}{vb:raw player_class_specops_xp}{vb:raw startendtablecell5}
{vb:raw starttablecell6}{vb:raw player_class_sniper_xp}{vb:raw endtablecell6}
{vb:raw starttablecell7}{vb:raw player_class_engineer_xp}{vb:raw endtablecell7}
{vb:raw starttablecell8}{vb:raw player_class_medic_xp}{vb:raw endtablecell8}
{vb:raw starttablecell9}{vb:raw $player_class_support_xp}{vb:raw endtablecell9}
{vb:raw endtablerow}
</table>
<div class="spacer"> </div>
</div>
<div class="spacer"></div>
{vb:raw footer}
</body>
</html>
So how would I be able to make the second bit of code using the templates to create the table rows like in the first standalone bfstats.php.
Thanks abunch in advanced.
|