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 10-15-2007, 12:27 AM
req2d req2d is offline
 
Join Date: Jul 2007
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Simple Plug-in not Working.

This is a continuation from another thread, but the content has already changed sig. from the original thread.

Trying to get the latest 6 thumbails to display under the navbar. "highlightthread" is indeed the name of the table as I forgot to add the prefix.

Here is the plugin:
PHP Code:
$highlightthreads $db->query_read("SELECT * FROM highlightthread ORDER BY reference DESC LIMIT 0, 6); 

while (
$row = mysql_fetch_array($highlightthreads)) {
echo "
<img src=".$row["imageurl"]." />";
    } 
Screenie: http://img80.imageshack.us/img80/1023/problemlf3.jpg

Last line on the navbar, I just plucked in $highlightthreads , but to no avail. Nothing is showing up in the source either when I load forumhome so I'm sure I've gone wrong somewhere.

Any ideas? Many thanks
Reply With Quote
  #2  
Old 10-15-2007, 07:00 PM
Analogpoint's Avatar
Analogpoint Analogpoint is offline
 
Join Date: Feb 2007
Posts: 656
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Instead of echoing the image tags, save them into a variable, and that's the variable you need to put in a template.
Reply With Quote
  #3  
Old 10-15-2007, 07:58 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$highlightthreads $db->query_read("SELECT * FROM highlightthread ORDER BY reference DESC LIMIT 0, 6"); 

while (
$row $db->fetch_array($highlightthreads)) 
{
    
$image .= '<img src='.$row['imageurl'] .' />';

Try that, then use $image in your template to show the images.
Reply With Quote
  #4  
Old 10-15-2007, 08:05 PM
Analogpoint's Avatar
Analogpoint Analogpoint is offline
 
Join Date: Feb 2007
Posts: 656
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's a good habit to initialize your variables $image = ''; before you start concatenating information onto it.
Reply With Quote
  #5  
Old 10-16-2007, 02:07 AM
req2d req2d is offline
 
Join Date: Jul 2007
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Analogpoint & Opserty,

Thank you very much for your help. I've edited the code to show this now:

edited, see below:


--------------- Added [DATE]1192514327[/DATE] at [TIME]1192514327[/TIME] ---------------

Interesting, when I load the PHP through logicians template it displays the last 6 as the code states. However when I run it through the plugin I only get the last value (i.e. the 6th). Any thoughts on what may be causing this? Note: $highlightimage is situated at the bottom of the navbar.

New code:

PHP Code:
$result = @mysql_query('SELECT reference, imageurl, threadurl FROM highlightthread ORDER BY reference DESC LIMIT 0, 6');
if (!
$result) {
exit(
'<p>Error performing query: ' mysql_error() . '</p>');
}

while (
$row mysql_fetch_array($result)) {
$highlightimage $row['reference'];

Thank you
Reply With Quote
  #6  
Old 10-16-2007, 06:43 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Change:
PHP Code:
$highlightimage $row['reference']; 
To:
PHP Code:
$highlightimage .= $row['reference']; 
Reply With Quote
  #7  
Old 10-16-2007, 01:24 PM
req2d req2d is offline
 
Join Date: Jul 2007
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you Marco, still a lot to learn

Think the only issue I really have left is now "how do I seperate the data?". Currently, it's outputting <a href="url1url2url3url4url5url6"> when I'd like it to create the link for each of the url's. Code now is as follows:

PHP Code:
$result = @mysql_query('SELECT reference, imageurl, threadurl FROM highlightthread ORDER BY reference DESC LIMIT 0, 6');
if (!
$result) {
exit(
'<p>Error performing query: ' mysql_error() . '</p>');
}

while (
$row mysql_fetch_array($result)) {
$threadurl .= $row['threadurl'];
$imageurl .= $row['imageurl'];
eval(
'$highlights = "' fetch_template('highlights') . '";');

Code in template $highlights, pretty straightforward..

PHP Code:
<a href="$threadurl"><img src="$imageurl"></a
Thank you again for all the support, learning a lot by all means.
Reply With Quote
  #8  
Old 10-16-2007, 02:04 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Change:
PHP Code:
while ($row mysql_fetch_array($result)) { 
$threadurl .= $row['threadurl']; 
$imageurl .= $row['imageurl']; 
eval(
'$highlights = "' fetch_template('highlights') . '";'); 

To:
PHP Code:
while ($row mysql_fetch_array($result)) 

 
$threadurl $row['threadurl']; 
 
$imageurl $row['imageurl']; 
 eval(
'$highlights .= "' fetch_template('highlights') . '";'); 

Reply With Quote
  #9  
Old 10-16-2007, 03:52 PM
req2d req2d is offline
 
Join Date: Jul 2007
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you Marco, that did the trick. I have been trying to figure out how to populate the thumbnails in 3 rows, 2 per row (total 6), i.e.:

thumb1 thumb2
thumb3 thumb4
thumb5 thumb6

Now obviously I could probably use 3 queries, but I'm thinking this is probably inefficient and there is a better solution. What function or code would I need to insert to make such possible?

Many thanks
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 07:44 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.04009 seconds
  • Memory Usage 2,264KB
  • 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
  • (9)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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