Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 04-10-2008, 10:12 PM
Masked Crusader Masked Crusader is offline
 
Join Date: Oct 2005
Location: Sacramento, CA, USA
Posts: 293
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Table On Forumhome -- Filling it with PHP/SQL Data

Hey guys. After trying to make this work in the header of my site, I have given up. It is making for a ton of alignment and sizing issues.

What I want to do now is have the PHP code make a new table and place it on the ForumHome page in line with the actual forums. Here is a mockup of what I am talking about:



The new table needs to have a column span of 2 because I want to seperate the loot winner and the actual name of the loot.

Here is my current code. I am using this as a plugin at the moment.

PHP Code:
$link mysql_connect('localhost''****''****') or die('Could not connect: ' mysql_error());

mysql_select_db('****') or die('Could not select database');

$query 'SELECT item_buyer, item_name FROM eqdkp_items ORDER BY raid_id DESC LIMIT 0,7';

$result mysql_query($query) or die('Query failed: ' mysql_error());

echo 
"<table width=400px align=right>";
echo 
"<tr><th colspan=1 align=center><b><u>Latest Loots</u></b></th></tr>";

while (list(
$buyer$item_name) = mysql_fetch_row($result)) {

$item_link "[item]".$item_name."[/item]";

$myMessage itemstats_parse($item_link);

echo (
"<tr><td align=right>".$myMessage." <b>".$buyer."</b></td></tr>");

}

echo 
"</table>";

mysql_free_result($result);

mysql_close($link); 

Any help would be appreciated.

Thanks.
Reply With Quote
  #2  
Old 04-11-2008, 04:24 PM
lithrel lithrel is offline
 
Join Date: Dec 2006
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you can, give the mysql vb user access to your eqdkp_items table, you won't need to create another connection to your database.

Don't echo anything in your plugin. You should just use the template system.
So, put a variable in your FORUMHOME template, where you want your table to appear; let's call it $winners.
HTML Code:
<if condition="!empty($winners)">
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr><th colspan="2">Latest loot</th></tr>
$winners
</table>
</if>
Then, your plugin should look like this:
PHP Code:
$winners="";
$result $vbulletin->db->query("SELECT item_buyer, item_name FROM YOUR_DB.eqdkp_items     ORDER BY raid_id DESC LIMIT 0,7")
while( list(
$buyer$item_name) = $vbulletin->db->fetch_row($result) ){
    
$item_link "[item]".$item_name."[/item]";
    
$myMessage itemstats_parse($item_link); // want to parse bbcode ?
    
$winners .= "<tr><td>".$buyer."</td><td>".$myMessage."</td></tr>";

Hook: forumhome_complete

$winners will be replace by its value during fetch_template('FORUMHOME') in index.php
Reply With Quote
  #3  
Old 04-11-2008, 04:43 PM
Masked Crusader Masked Crusader is offline
 
Join Date: Oct 2005
Location: Sacramento, CA, USA
Posts: 293
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by lithrel View Post
If you can, give the mysql vb user access to your eqdkp_items table, you won't need to create another connection to your database.
How do I go about this?

Thank you very much for your help.
Reply With Quote
  #4  
Old 04-11-2008, 04:51 PM
lithrel lithrel is offline
 
Join Date: Dec 2006
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

On phpmyadmin, privileges => edit the user used by your forum
see 'Database-specific privileges'
Select the database that contain your eqdkp_items table, and give SELECT right on the database or the table.

edit: just added YOUR_DB before the table name in the sql query, don't forget to change it
Reply With Quote
  #5  
Old 04-11-2008, 07:33 PM
MoT3rror MoT3rror is offline
 
Join Date: Mar 2007
Posts: 423
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If the table is in the same database as your vbulletin, you don't need to worry about giving the MySQL user access to the table.
Reply With Quote
Reply

Thread Tools
Display Modes

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 02:58 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.06099 seconds
  • Memory Usage 2,208KB
  • 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_html
  • (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
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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