Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools
Latest Attachment of 1st Post in Forums Details »»
Latest Attachment of 1st Post in Forums
Version: , by Ian Cunningham Ian Cunningham is offline
Developer Last Online: Jul 2018 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 09-07-2002 Last Update: Never Installs: 0
 
No support by the author.

OK, this is one hell of a confusing thing for me to get my head round, so I was wondering someone can lend a hand here

Check out http://www.pcreview.co.uk/index.php and you will see "Latest Articles" at the top - all of that I have to add manually everytime I create a review in one of the review forums.

If you check the image source, the source file is actually the attachment of the first post in the review thread. I want to get the latest four review images from my database and insert them on my main page - does anyone know how I would do this? (each post in the same review has the same attachment, so just getting the latest 4 images from a specific forum would not work).

Any ideas?

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 09-07-2002, 08:35 PM
Issvar Issvar is offline
 
Join Date: Mar 2002
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

SELECT postid FROM post LEFT JOIN thread ON thread.threadid=post.threadid WHERE thread.forumid IN (xx,xy,xz) AND thread.dateline=post.dateline ORDER BY post.dateline DESC LIMIT 4

That's the mysql statement you probably want. It gets the postids from the first posts of the latest threads in the forums with forumid xx,xy and xz (change as required). Avatars are accessed by their postid so you should be able to use them now easily. You can add getting the post content to that mysql statement so you can automize that as well. To do so just replace the SELECT postid with SELECT postid, pagetext
Reply With Quote
  #3  
Old 09-08-2002, 09:37 AM
Ian Cunningham Ian Cunningham is offline
 
Join Date: Feb 2002
Posts: 221
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks

So far I am 50% of the way there, and I'm using this code:

PHP Code:
<?php
require('./admin/config.php');

//connect
$connection mysql_connect("$servername","$dbusername","$dbpassword") or die ("Cannot connect to server.");

//select database
$db mysql_select_db("$dbname"$connection) or die ("Could not select database.");

// create sql statement
$sql "SELECT postid FROM post LEFT JOIN thread ON thread.threadid=post.threadid WHERE thread.forumid IN (22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38) AND thread.dateline=post.dateline ORDER BY post.dateline DESC LIMIT 4";

//execute sql query
$sql_result mysql_query($sql$connection) or die ("Could not execute query.");

while (
$row mysql_fetch_array($sql_result)) {
   
$postid $row["postid"];
}
echo 
"

<img src=\"http://www.pcreview.co.uk/attachment.php?postid=
$postid\" border=\"0\">

"
;

mysql_free_result($sql_result);
mysql_close($connection);
?>
What I really need is to get the $threadid of that post, the $postid (which works!), and the $title. This code currently displays the 4th last image to be attached in those forums, can you help me modify it so all the last 4 are, and so I can call $threadid and $title too?
Reply With Quote
  #4  
Old 09-08-2002, 01:49 PM
Issvar Issvar is offline
 
Join Date: Mar 2002
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
<?php
require('./admin/config.php');

//connect
$connection mysql_connect("$servername","$dbusername","$dbpassword") or die ("Cannot connect to server.");

//select database
$db mysql_select_db("$dbname"$connection) or die ("Could not select database.");

// create sql statement
$sql "SELECT postid,post.threadid,post.title FROM post LEFT JOIN thread ON thread.threadid=post.threadid WHERE thread.forumid IN (22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38) AND thread.dateline=post.dateline AND post.attachmentid!=0 ORDER BY post.dateline DESC LIMIT 4";

//execute sql query
$sql_result mysql_query($sql$connection) or die ("Could not execute query.");

while (
$row mysql_fetch_array($sql_result)) {
   list(
$postid,$threadid,$title)=$row;
   echo 
"

<img src=\"http://www.pcreview.co.uk/attachment.php?postid=
$postid\" border=\"0\">

   "
;
}

mysql_free_result($sql_result);
mysql_close($connection);
?>
Changes I made: I put the echo command inside the while loop, so it will execute once for each row, instead of only once total;
I added getting titles and threadids and put those in their variables (be sure to stripslashes() on the title or it will have slashes in front of quotesigns);
I made sure the sql statement doesn't get posts that don't have attachments.
Reply With Quote
 


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 02:35 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.03687 seconds
  • Memory Usage 2,245KB
  • Queries Executed 19 (?)
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
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (3)postbit
  • (4)postbit_onlinestatus
  • (4)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