Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
pulling data from other table for postbit Details »»
pulling data from other table for postbit
Version: , by Shepski Shepski is offline
Developer Last Online: Apr 2008 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 07-08-2003 Last Update: Never Installs: 0
 
No support by the author.

Hiya,

I am working on a hack and I am nowstuck on how to pull data from one field from a different table within my main vb db and then attach that to each user. the other table is created for users who subscribe so I want to add an extra bit to their postbit which displays "subscribed" or something similar. The other table is called adult and has fields called, uid (which contians the users forumid), fname (forum username), email (forum email address) and datesigned (has the date they subscribed). I have played around with the showthread but no success as yet.

any help on where to look appreciated

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 07-08-2003, 02:54 PM
Gavin B. Gavin B. is offline
 
Join Date: Jul 2003
Location: Australia
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

use a join

not sure what your query looks like, but it sounds like you need a LEFT JOIN. Should be pretty simple, here's a small article on joins -http://www.devshed.com/Server_Side/MySQL/SQLJoins/

Reply With Quote
  #3  
Old 07-08-2003, 03:20 PM
Shepski Shepski is offline
 
Join Date: Jul 2002
Posts: 72
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i had a look at the join statement earlier but could get it to work. this is what i ended up with:
Code:
$adult=$DB_site->query("SELECT users.userid FROM users
LEFT JOIN adult ON adult.uid = users.userid, adult.extrapostbit as extrabit WHERE adult.uid = users.userid
");
but i just keep getting mysql errors and alot of annoyed users as they keep trying to post as I make the changes and mess things up!

how close am I? the postbitextra is the bit i want to pull into the postbit and display for each user in the thread view which I presume will end up being something like $adult[extrabit] in the postbit template in-order to display it.
Reply With Quote
  #4  
Old 07-08-2003, 05:54 PM
Gavin B. Gavin B. is offline
 
Join Date: Jul 2003
Location: Australia
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

in showthread.php at around line 400ish

PHP Code:
$posts=$DB_site->query("
SELECT
post.*,post.username AS postusername,post.ipaddress AS ip,user.*,userfield.*,adult.*,"
.iif($forum[allowicons],'icon.title as icontitle,icon.iconpath,','')."
attachment.attachmentid,attachment.filename,attachment.visible AS attachmentvisible,attachment.counter
"
.iif($avatarenabled,",avatar.avatarpath,NOT ISNULL(customavatar.avatardata) AS hascustomavatar,customavatar.dateline AS avatardateline","")."
FROM post
"
.iif($forum[allowicons],'LEFT JOIN icon ON icon.iconid=post.iconid','')."
LEFT JOIN user ON user.userid=post.userid
LEFT JOIN userfield ON userfield.userid=user.userid
"
.iif ($avatarenabled,"LEFT JOIN avatar ON avatar.avatarid=user.avatarid
                       LEFT JOIN customavatar ON customavatar.userid=user.userid"
,"")."
LEFT JOIN attachment ON attachment.attachmentid=post.attachmentid
LEFT JOIN adult ON adult.uid=user.userid
WHERE 
$postids
ORDER BY dateline 
$postorder
"
); 
should do it, I haven't (can't really) tested it... but I would say it should work.

You can refer to your fields as normal in your template
Reply With Quote
  #5  
Old 07-08-2003, 07:18 PM
Shepski Shepski is offline
 
Join Date: Jul 2002
Posts: 72
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

edit: oops! my bad!

just realised that adult.uid should actually be adult.fid! it now runs but not sure if it is working. I am calling $adult[extra] in the postbit but its not pulling the info in. Am i right in calling $adult[extra]?
Reply With Quote
  #6  
Old 07-08-2003, 09:40 PM
Gavin B. Gavin B. is offline
 
Join Date: Jul 2003
Location: Australia
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You should be able to do it with $post[extra]
Reply With Quote
  #7  
Old 07-09-2003, 07:16 AM
Shepski Shepski is offline
 
Join Date: Jul 2002
Posts: 72
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

duh! now you see what your working with...a complete numpty! That all works a sweet as a nut now

My next little challenge is to get it to display this extra field in the user info. I have looked in member.php and in the start get info section added the following:
Code:
$extrabit=$DB_site->query("SELECT extra FROM adult WHERE fid = '$userid'");
as there wasnt a statement in their to JOIN to but as you have already guessed, its doesnt appear to work. Also, I am not sure how to add some code to that so if the fid != userid to do nothing and not fall over with an error.

Any clues on this?
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 10:34 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.06157 seconds
  • Memory Usage 2,261KB
  • Queries Executed 20 (?)
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
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (6)postbit
  • (7)postbit_onlinestatus
  • (7)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