View Full Version : attachment associations
sccr410
02-18-2002, 07:39 AM
How does vB check which attachment is associated with which thread? In the 'thread' table, it just has a variable to determine if there is an attachment, and in the 'attachment' table it only has attachmentid.
I am trying to modify a news system to display a link to a file attachment at the end of the post.
http://www.sandiegopegasus.com uses vB as the news system and many times there are file attachments. This would be *very* helpful!
Thanks for any help!
Admin
02-18-2002, 07:48 AM
Let's say you have $attachmentid:
$getthreadid=$DB_site->query_first("SELECT threadid FROM post WHERE attachmentid=".intval($attachmentid));
$threadid=$getthreadid['threadid'];
The only problem is, when one attachment belongs to one or more posts (happens when you copy a thread, and a post has an attachment).
sccr410
02-18-2002, 09:26 AM
Fatal error: Call to a member function on a non-object in /home/sandieg/public_html/forum/PluhNews.php on line 68
Line 68 begins the code you started.
?
Admin
02-18-2002, 09:43 AM
Use regular mysql_query() if it's not a vBulletin page.
sccr410
02-18-2002, 09:31 PM
So actually it was even easier than that. You don't need to do another sql query because the news program already gets the postid, which is all you need.
if ($attach == 1) {
$displayattach = "<small><a href=http://www.sandiegopegasus.com/forum/attachment.php?postid=".$postid.">Download attachment</a>";
}
else { $displayattach = ""; }
Admin
02-19-2002, 11:07 AM
You are welcome.
sccr410
02-19-2002, 04:30 PM
Thanks FireFly. You got me to actually think about how it works and I actually did something on my own!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.