vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Queries on Custom Pages with Multiple Results (https://vborg.vbsupport.ru/showthread.php?t=285710)

evenmonkeys 07-19-2012 01:47 AM

Queries on Custom Pages with Multiple Results
 
I know that the answer exists somewhere.. I just have no idea what I should be searching for.

I have a custom table with userids, win and losses for a game I made. I want to display these results on a custom page using only plugins and templates. I'd rather not create a physical file.

Can someone please point me in the right direction? I don't understand how to create a query in the plugin and display it in the template.

Thanks.

kh99 07-19-2012 09:47 AM

If you don't want to create a new file, you can use a plugin on hook misc_start and have your plugin check for a specific value of $_REQUEST['do'], like:
Code:

if ($_REQUEST['do'] == 'game_stats')
{
  // Format and return your page (such as by calling print_output()).  If your plugin
  // doesn't end the script you will see the list of smilies.
}


then the url for your page would be misc.php?do=game_stats.


To format your page, you would do your query then build a string with the results, then probably use that string in a template, like:
Code:

if ($_REQUEST['do'] == 'game_stats')
{
    $results = $vbulletin->db->query("SELECT * FROM game_results ORDER BY ...whatever");
 
    $stats = "";
    while ($row = $vbulletin->db->fetch_array($results))
    {
        $stats .= "Wins: $row[wins] Loses: $row[loses]<BR/>";
    }
    // the game_stats template used below would have to be a full html page that includes $stats somewhere.
  // probably easiest to copy an existing full page template and delete the parts you don't need.
    eval('print_output("' . fetch_template('game_stats') . '");'); // print_output doesn't return, script ends.
}


You could also use a small template to format your game stats if you prefer, rather than putting html formatting in your plugin code.

evenmonkeys 07-20-2012 03:49 AM

You are easily the most helpful person I have ever dealt with on this website. No credit taken away from the others that have helped me.. but you are awesome.

Thank you so much. Works perfectly.


All times are GMT. The time now is 06:24 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.01040 seconds
  • Memory Usage 1,711KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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