vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vbBux / vbPlaza (https://vborg.vbsupport.ru/forumdisplay.php?f=171)
-   -   vBadvanced Module to show Lotto jackpots, endtime, and number of tickets owned/sold (https://vborg.vbsupport.ru/showthread.php?t=124559)

Quarterbore 08-21-2006 02:29 PM

vBadvanced Module to show Lotto jackpots, endtime, and number of tickets owned/sold
 
1 Attachment(s)
OK, this code is really not optomized but the MYSQL coding of this is just a little above my own skill. So, I am sharing my vBa module with the hopes that someone can help optomize it as right now I query the database FOUR times in this tiny block!

It works as is but I know someone with more skill then I have would be able to make it work better....

Here are some notes:

I hard coded the two lotteries I use on my site lotteryid = '1' and lotteryid = '2'. I did this as I couldn't figure out how to do this in an array. I also did not program this with phrases as I have no plans to use this in multiple languages.

Here is the code:

PHP Code:

<?php
    
// search for the lottery
    
$weeklylottery $vbulletin->db->query_first("SELECT jackpot,enddateline,ticketssold FROM " TABLE_PREFIX "vbplaza_lottery WHERE lotteryid = '1' AND active = 1");
        
// count how many times this user has purchased a ticket for the weekly lottery
        
$weeklyticketsowned $vbulletin->db->query_first("
            SELECT COUNT(*) AS count
            FROM " 
TABLE_PREFIX "vbplaza_lotteryticket
            WHERE lotteryid = '1'
                AND userid = '" 
$vbulletin->userinfo['userid'] . "'
        "
);
    
$dailylottery $vbulletin->db->query_first("SELECT jackpot,enddateline,ticketssold FROM " TABLE_PREFIX "vbplaza_lottery WHERE lotteryid = '2' AND active = 1");
        
// count how many times this user has purchased a ticket for the daily lottery
        
$dailyticketsowned $vbulletin->db->query_first("
            SELECT COUNT(*) AS count
            FROM " 
TABLE_PREFIX "vbplaza_lotteryticket
            WHERE lotteryid = '2'
                AND userid = '" 
$vbulletin->userinfo['userid'] . "'
        "
);

    
$daily['jackpot'] = number_format($dailylottery['jackpot'], $vbulletin->options['vbplaza_decimalplaces']);
    
$daily['enddate'] = vbdate($vbulletin->options['dateformat'] . ', ' $vbulletin->options['timeformat'], $dailylottery['enddateline']);


    
$weekly['jackpot'] = number_format($weeklylottery['jackpot'], $vbulletin->options['vbplaza_decimalplaces']);
    
$weekly['enddate'] = vbdate($vbulletin->options['dateformat'] . ', ' $vbulletin->options['timeformat'], $weeklylottery['enddateline']);


echo 
'<tr><td><div class="smallfont">';

echo 
'Daily Lotto: ' $daily['jackpot'] . '<br />' ;
echo 
$daily['enddate']  . '<br />';
echo 
'You own ' $dailyticketsowned[count] . ' of the ' $dailyticketssold ' tickets.<br /><br />';

echo 
'Weekly Lotto: ' $weekly['jackpot']  . '<br />';
echo 
$weekly['enddate']  . '<br />';
echo 
'You own ' $weeklyticketsowned[count] . ' of the ' $weekticketssold ' tickets.<br />';


echo 
'</td></tr></div>';

?>


Attached is a screenshot...

Thanks for any help improving this!


All times are GMT. The time now is 03:28 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.01578 seconds
  • Memory Usage 1,732KB
  • 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
  • (1)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