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

Reply
 
Thread Tools
trouble with forumdisplay.php Details »»
trouble with forumdisplay.php
Version: , by jsell jsell is offline
Developer Last Online: Sep 2004 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 10-23-2002 Last Update: Never Installs: 0
 
No support by the author.

I hope someone can help me. I am trying to to figure out a way to pull a variable from a table seoperate from the threads table and have a value show in the forumdisplaybit. I try to place a query right after this code in forumdisplay.php

PHP Code:
while ($thread=$DB_site->fetch_array($threads)) { // and $counter++<$perpage) { 

but it doesn't seem to get the info from the DB is there i think i am placing this code incorrectly hope i explained this well enough
and that someone can help me

Thnaks in advance

jsell

Show Your Support

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

Comments
  #2  
Old 10-23-2002, 03:02 AM
Erwin's Avatar
Erwin Erwin is offline
 
Join Date: Jan 2002
Posts: 7,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What is the variable and how are you writing the query line? Post exactly what you put down and where in forumdisplay.
Reply With Quote
  #3  
Old 10-23-2002, 03:43 AM
jsell jsell is offline
 
Join Date: Nov 2001
Location: South USA
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

the query i used is


PHP Code:
$reqdata=$DB_site->query_first("SELECT * from reqdata WHERE threadid=$threadinfo[threadid]"); 

this should return a variable i want to return is $reqdata[status]
a 1 or 0 to signify a yes or no which will the each open there own template to place into the forumdisplaybit and appear on nt appear based on the variable (i think that makes sense....lol) but i get novalue at all for any variable eventhough the data is there in the database

--jsell
Reply With Quote
  #4  
Old 10-23-2002, 02:20 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you know it's not good to have a query within a whileloop?

you should use a join-query instead.

nevertheless i think your where clause is wrong use this:
PHP Code:
$reqdata=$DB_site->query_first("SELECT * from reqdata WHERE threadid=$thread[threadid]"); 
$threadinfo isn't defined as i know
Reply With Quote
  #5  
Old 10-23-2002, 09:16 PM
jsell jsell is offline
 
Join Date: Nov 2001
Location: South USA
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well I fixed the problem with the variable, but now you have me intrigued as i am aparently not doing the correct way. If someone would kindly expalin to me how the join-Query Xenon is refering to should work I would like to know.

Thanks in advance

--jsell
Reply With Quote
  #6  
Old 10-23-2002, 09:21 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well, somewhere in your script you define the $threads variable:

Code:
$threads=$DB_site->query("SELECT * FROM thread WHERE ...
to use a join query you have to chang it into this:
Code:
$threads=$DB_site->query("SELECT thread.*,reqdata.* FROM thread LEFT JOIN reqdata USING(threadid) WHERE ...
then you don't need the query in th while loop anymore, you can acces to all data within reqdata table throug $thread variable
Reply With Quote
  #7  
Old 10-23-2002, 09:28 PM
jsell jsell is offline
 
Join Date: Nov 2001
Location: South USA
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Again Xenon!!

A quick reply too . it's not an issue in this particular case but for future reference I can see how this could cause one problem though if there are identically named fields in the two different tables then there would be a conflict is there a way around this??

--jsell
Reply With Quote
  #8  
Old 10-23-2002, 09:40 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you're welcome

if you have fields with identical names you shouldn't use the * use explicit names instead:

Code:
$threads=$DB_site->query("SELECT thread.threadid, thread.title,reqdata.title AS reqtitle FROM thread LEFT JOIN reqdata USING(threadid) WHERE ...
as you can see, the field title in table reqdata can be accesed throug $thread[reqtitle].

you can use the AS operator whenever you have two fields with same names to rename on of them
Reply With Quote
  #9  
Old 10-23-2002, 09:42 PM
jsell jsell is offline
 
Join Date: Nov 2001
Location: South USA
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I See Now!! Thank you again for all you help

--jsell
Reply With Quote
  #10  
Old 10-23-2002, 09:44 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

welcome

that's why i'm here.

if you have other questions, feel free to post, there are many people out which can help
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 01:21 PM.


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.04453 seconds
  • Memory Usage 2,297KB
  • Queries Executed 23 (?)
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
  • (3)bbcode_code
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete