Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
Prev Previous Post   Next Post Next
  #1  
Old 02-01-2004, 12:20 PM
dontpanic dontpanic is offline
 
Join Date: Jun 2003
Posts: 145
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help in writing SQL query

EDIT: Now I would like to do this in vB 3.6 (last post).

I would like to have a bit of code in the showthread.php file and showthread template to accomplish the following task: I'd like to have different information shown in the header depending on what forumid is being viewed. I've currently accomplished this in vB 3.x using <if> conditionals in the showthread tempalte, but this is making the showthread template VERY long and I've seen a few random errors since I've implemented it that I think may be attributable to the length of the showthread template.

What I'd rather do is have the query pull the results of the DB depending on what forumid is being shown and pass them into the template using a variable. I'm not sure how to write the query and such. I will only have two fields in the table, forumid and content. I'd like it such that if the forumid being viewed on the showthread.php page is equal to one that is in the table it shows that defined content. If there is no match, I'd like it such that the query returned some default row from the table.

If you're curious as to what I'm really trying to do, have a look at my forums. On this page, you can see the header information (which is inserted by the showthread template) has information on books for the 70-292 exam:
http://www.mcseworld.com/forums/showthread.php?t=12495

On this one, it has information on books for the 70-296 exam:
http://www.mcseworld.com/forums/showthread.php?t=12522

And so forth. Like I mentioned previously, this is currently being done by a rather large chunk of HTML with conditionals in the showthread template. Here is an example of that for one of the forums:
PHP Code:
<!-- 70-292 -->
<if 
condition="$foruminfo['forumid']==114">

<
div align="center">
  <
center>

<
table class="tborder" cellpadding="0" cellspacing="$stylevar[cellspacing]border="0" width="100%" style="border-collapse: collapse" bordercolor="#111111">

<
tbody>
    <
tr>
        <
td class="thead" colspan="5" width="100%" align="left" valign="top">
            <
a style="float:$stylevar[right]href="#top" onclick="return toggle_collapse('forumhome_poparticles')"><img id="collapseimg_forumhome_poparticles" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_poparticles].gif" alt="" border="0" /></a>MCSE 
            World Recommended Reading
</td>
    </
tr>
</
tbody>
<
tbody id="collapseobj_forumhome_poparticles" style="$vbcollapse[collapseobj_forumhome_poparticles]">
    <
tr>
        <
td class="alt1Active" width="100%" align="left" valign="top" colspan="5">
        <
span class="smallfont"><b>Exam 70-292:&nbspManaging and Maintaining a 
        Microsoft Windows Server 2003 Environment 
for an MCSA Certified on 
        Windows 2000.
&nbsp;&nbsp; </b></span></td>
    </
tr>
        <
tr>
        <
td class="alt1Active" width="20%" align="center" valign="top">
        <
a href="http://www.mcseworld.com/a/1932266569" target="_blank">
        <
IMG SRC="http://images.amazon.com/images/P/1932266569.01.MZZZZZZZ.jpg" width="111" height="140" border="0"></a></td>
        <
td class="alt1Active" width="20%" align="center" valign="top">
        <
a href="http://www.mcseworld.com/a/0789729466" target="_blank">
        <
img border="0" src="http://images.amazon.com/images/P/0789729466.01.MZZZZZZZ.jpg" width="93" height="140"></a></td>
        <
td class="alt1Active" width="20%" align="center" valign="top">
        <
a href="http://www.mcseworld.com/a/0782142672" target="_blank">
        <
img border="0" src="http://images.amazon.com/images/P/0782142672.01.MZZZZZZZ.jpg" width="116" height="140"></a></td>
        <
td class="alt1Active" width="20%" align="center" valign="top">
        <
a href="http://www.mcseworld.com/a/0735619719" target="_blank">
        <
img border="0" src="http://a1055.g.akamai.net/f/1055/1401/5h/images.barnesandnoble.com/images/7040000/7042064.gif" width="100" height="132"></a></td>
        <
td class="alt1Active" width="20%" align="center" valign="top">
        <
a href="http://www.mcseworld.com/a/1932266615" target="_blank">
        <
img border="0" src="http://images.amazon.com/images/P/1932266615.01.MZZZZZZZ.jpg" width="111" height="140"></a></td>
        </
tr>
        <
tr>
        <
td class="alt1Active" width="100%" align="center" valign="top" colspan="5"><div class="smallfont">
        <
b>Please help support MCSE World by purchasing your study materials 
        through these links to Amazon
.com.</b></div></td>
    </
tr>
</
tbody>
</
table>
  </
center>
</
div>
<
br>
</if>
<!-- 
70-292 --> 
If pulling the information from the database, I'd obviously just have to code the table itself and the rest of the data would be in the DB and passed via the output variable of the SQL query.

Thanks in advance.
Reply With Quote
 

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 11:29 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.06280 seconds
  • Memory Usage 2,510KB
  • Queries Executed 12 (?)
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
  • (5)bbcode_code
  • (7)bbcode_php
  • (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)showthread_list
  • (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_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • 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_threaded
  • showthread_threaded_construct_link
  • 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