vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Simple Plug-in not Working. (https://vborg.vbsupport.ru/showthread.php?t=160262)

req2d 10-15-2007 12:27 AM

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 :)

Analogpoint 10-15-2007 07:00 PM

Instead of echoing the image tags, save them into a variable, and that's the variable you need to put in a template.

Opserty 10-15-2007 07:58 PM

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.

Analogpoint 10-15-2007 08:05 PM

It's a good habit to initialize your variables $image = ''; before you start concatenating information onto it.

req2d 10-16-2007 02:07 AM

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 :)

Marco van Herwaarden 10-16-2007 06:43 AM

Change:
PHP Code:

$highlightimage $row['reference']; 

To:
PHP Code:

$highlightimage .= $row['reference']; 


req2d 10-16-2007 01:24 PM

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.

Marco van Herwaarden 10-16-2007 02:04 PM

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') . '";'); 



req2d 10-16-2007 03:52 PM

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 :)


All times are GMT. The time now is 07:58 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.01213 seconds
  • Memory Usage 1,752KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete