vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   attachment query (https://vborg.vbsupport.ru/showthread.php?t=52280)

colicab-d 04-28-2003 11:19 AM

attachment query
 
Hey.. I got a bit of a problem

Im ok at php but my mysql knowledge is a bit shoddy.. my question is what would be the coorect way to query the attachments, to show say the last 10 by forum id?

Ive been looking thru attachment.php but im a bit stuck and my last few attempts have returned invalid mysql queries :p

Xenon 04-28-2003 03:29 PM

hmm, attachments aren't stored with the forumid, because it would make some problems

you can try that way:

[sql]
SELECT attachment.attachmentid
FROM attachment
LEFT JOIN post USING(postid)
LEFT JOIN thread USING(threadid)
WHERE thread.forumid = X
ORDER by attachment.dateline DESC
LIMIT 10[/sql]

colicab-d 04-28-2003 03:30 PM

thnx xenon i will try this out ;)

colicab-d 04-28-2003 03:41 PM

PHP Code:

$showattach=$DB_site->query_first("SELECT attachment.attachmentid
                                   FROM attachment
                                   LEFT JOIN post USING(postid)
                                   LEFT JOIN thread USING(threadid)
                                   WHERE thread.forumid = 11
                                   ORDER by attachment.dateline DESC
                                   LIMIT 10"
); 

iswhat i used however i got this error

Quote:

Database error in vBulletin 2.2.9:

Invalid SQL: SELECT attachment.attachmentid
FROM attachment
LEFT JOIN post USING(postid)
LEFT JOIN thread USING(threadid)
WHERE thread.forumid = 11
ORDER by attachment.dateline DESC
LIMIT 10
mysql error: Unknown column 'attachment.postid' in 'on clause'

mysql error number: 1054

Date: Monday 28th of April 2003 05:01:34 PM
Script: http://www.artorg.co.uk/cupboards/cupboards/10last.php
Referer:
have i done something wrong? or is it just not working lol

Xenon 04-28-2003 03:47 PM

hmm, i think it's my fault ;)

replace USING(postid) with USING(attachmentid)

colicab-d 04-28-2003 03:51 PM

ok that worked great :D my next question is, what should i echo to get the results (soz im needing so much help, i can code most of this but this part is a bit complex)

Xenon 04-28-2003 03:54 PM

hmm i think a linkt to attachment.php with attachment id would fit in perfectly ;)

but i don'T exactly see what you want ;)

colicab-d 04-28-2003 03:59 PM

well im trying to get it so that it will output an image of each attachement, i.e in the case of images the actual image, and if its a file it will show a default image, ( i know how to do that ) its just getting it to show the last x amount of images in actaul jpg or gif format etc on a page that im having a few probs with..

like the query to get them and what needs to be echo`d

colicab-d 04-28-2003 10:31 PM

bump

Xenon 04-29-2003 04:23 PM

look at that part of the postbit to see how to put out an attachment, i'm sure you can work something out of it :)

just get the needed values out of the attachmenttable ;)

PHP Code:

    if ($post[attachmentid]!=and $post[attachmentvisible]) {
        
$post[attachmentextension]=strtolower(getextension($post[filename]));
        
$post['filename'] = censortext(htmlspecialchars($post['filename']));
        if (
$post[attachmentextension]=="gif" or $post[attachmentextension]=="jpg" or $post[attachmentextension]=="jpeg" or $post[attachmentextension]=="jpe" or $post[attachmentextension]=="png") {
            if ((
$viewattachedimages) and ($bbuserinfo[userid]==or $bbuserinfo[showimages])) {
                eval(
"\$post[attachment] = \"".gettemplate("postbit_attachmentimage")."\";");
            } else {
                eval(
"\$post[attachment] = \"".gettemplate("postbit_attachment")."\";");
            }
        } else {
            eval(
"\$post[attachment] = \"".gettemplate("postbit_attachment")."\";");
        }
    } else {
        
$post[attachment]="";
    } 



All times are GMT. The time now is 08:05 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.01062 seconds
  • Memory Usage 1,747KB
  • 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
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete