Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-13-2006, 01:48 AM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help with mysql select and array

Okay, so what I'm trying to do here is have a table underneath the member.php (memberinfo template) page with game statistics that are stored in a db. I've got a profile field set up where the users put in their username for the game -- that's how their stats are pulled from the table. So, table configuration: I've got around 9 or 10 fields, with things like kills, deaths, headshots, etc. What I'm trying to do is run a select query like: "SELECT * FROM table_name WHERE name = '$post[field5]'" And from this, I want to generate an array so I can use $stat[kills] or w/e in a template to post the row data from the kills field. Does that make sense? Anyway -- thanks in advance for any help. It's much appreciated.

I've tried a bunch of codes that people have posted with similar problems -- but none of them yield any results.
Reply With Quote
  #2  
Old 05-13-2006, 05:33 PM
Chroder's Avatar
Chroder Chroder is offline
 
Join Date: Sep 2003
Location: Toronto, Ontario
Posts: 112
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So the table has columns for kills, deaths etc? So all you need is a single row.

Something like this?

PHP Code:
$game_uname $vbulletin->db->sql_prepare($userinfo['field5']);

$stats $vbulletin->db->query_first("SELECT * FROM tablename WHERE name = $game_uname LIMIT 1"); 
Reply With Quote
  #3  
Old 05-13-2006, 06:16 PM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I tried using the code you supplied, but nothing shows up when I use the $stats var in a template. But yes, that's how my table is set up.
Reply With Quote
  #4  
Old 05-13-2006, 06:26 PM
Chroder's Avatar
Chroder Chroder is offline
 
Join Date: Sep 2003
Location: Toronto, Ontario
Posts: 112
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Which hook are you using?
Reply With Quote
  #5  
Old 05-13-2006, 08:44 PM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

global_complete
Reply With Quote
  #6  
Old 05-13-2006, 08:54 PM
Chroder's Avatar
Chroder Chroder is offline
 
Join Date: Sep 2003
Location: Toronto, Ontario
Posts: 112
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

global_complete is too late, and global

Try using member_complete instead.
Reply With Quote
  #7  
Old 05-13-2006, 09:11 PM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah ha! That did it, that'd explain why my other codes weren't working -- he he. Thanks a lot Chroder!

Edit: Oh and Chroder -- do you by chance know how I can connect to a seperate database with this?
Reply With Quote
  #8  
Old 05-15-2006, 07:06 PM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Bump: Connecting to another database?
Reply With Quote
  #9  
Old 05-16-2006, 11:58 AM
hambil's Avatar
hambil hambil is offline
 
Join Date: Jun 2004
Location: Seattle
Posts: 1,719
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by acidburn0520
Bump: Connecting to another database?
PHP Code:
    switch (strtolower($vbulletin->config['Database']['dbtype']))
    {
        
// load standard MySQL class
        
case 'mysql':
        case 
'':
        {
            
$db_temp =& new vB_Database($vbulletin);
            break;
        }
        
// load MySQLi class
        
case 'mysqli':
        {
            
$db_temp =& new vB_Database_MySQLi($vbulletin);
            break;
        }
    }
    
    
$db_temp->connect(
        
$vbulletin->config['Database']['dbname'],
        
$vbulletin->config['MasterServer']['servername'],
        
$vbulletin->config['MasterServer']['port'],
        
$vbulletin->config['MasterServer']['username'],
        
$vbulletin->config['MasterServer']['password'],
        
true
    
); 
Reply With Quote
  #10  
Old 05-16-2006, 07:32 PM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What should I change my select code to?
Code:
$stats = $vbulletin->db->query_first("SELECT * FROM stats_new WHERE name = $game_uname");
Edit: Nevermind, I'm such an idiot -- lol. Thanks for the assist hambil.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:53 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06290 seconds
  • Memory Usage 2,262KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete