Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-28-2003, 11:19 AM
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Location: Glasgow
Posts: 382
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 04-28-2003, 03:29 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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]
Reply With Quote
  #3  
Old 04-28-2003, 03:30 PM
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Location: Glasgow
Posts: 382
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thnx xenon i will try this out
Reply With Quote
  #4  
Old 04-28-2003, 03:41 PM
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Location: Glasgow
Posts: 382
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #5  
Old 04-28-2003, 03:47 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm, i think it's my fault

replace USING(postid) with USING(attachmentid)
Reply With Quote
  #6  
Old 04-28-2003, 03:51 PM
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Location: Glasgow
Posts: 382
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok that worked great 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)
Reply With Quote
  #7  
Old 04-28-2003, 03:54 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

but i don'T exactly see what you want
Reply With Quote
  #8  
Old 04-28-2003, 03:59 PM
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Location: Glasgow
Posts: 382
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #9  
Old 04-28-2003, 10:31 PM
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Location: Glasgow
Posts: 382
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

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]="";
    } 
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:38 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06081 seconds
  • Memory Usage 2,272KB
  • Queries Executed 13 (?)
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
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)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
  • (10)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_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
  • 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