vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Accessing field in first 'post' per thread (https://vborg.vbsupport.ru/showthread.php?t=67956)

MacMorag 08-03-2004 12:56 PM

Accessing field in first 'post' per thread
 
You know how sometimes you look at a problem for so long that you begin to wonder what it is you're trying to do in the first place? Well, I'm there :ermm:

What I'm trying to do:

Every thread has an associated 'first' post. Correct.

I would like to access a specific field in this 'first' post, for a dynamic range of threadids, and be able to access the contents of this field.

e.g. Thread with 'threadid' of '123', has a first post whose 'postid' is '456'. This post (postid=456) has a field called 'sample' which contains "ABC".

I'd like to access the contents of 'sample' when I only have the 'threadid' as a reference point to start with.

So 'threadid' 100 returns "ABC".

What SQL statement do I need to use to get to this data? I know how to extract the first 'postid' for a thread. How do I then extract a specific field from the post?

Thanks for any help.

Natch 08-03-2004 01:04 PM

How do you wanna access it ? in the postbit ?
PHP Code:

<if condition="$post[postcount] == 1">
    <if 
condition="$post[sample]">$post[sample]</if>
</if> 

Will that do the trick ?

Colin F 08-03-2004 01:05 PM

[SQL]SELECT post.sample FROM thread LEFT JOIN post on thread.firstpostid = post.postid WHERE thread.threadid = $threadid[/SQL]


something like that should work, change if you have table prefixes.

MacMorag 08-03-2004 01:10 PM

Hi Natch,

No, I want to access it from index.php

1. I have added a field to the post table called "sample", which is written to when the FIRST post is submitted.

2. I am displaying the latest 10 threads on index.php, and I would like to display the contents of "sample" for each.

Thanks, Morag.

Natch 08-03-2004 01:12 PM

Colin F read your post and has it right :)

MacMorag 08-03-2004 01:12 PM

Thanks Colin - that should do the trick.

Headache receding already :)


All times are GMT. The time now is 06:30 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.02192 seconds
  • Memory Usage 1,716KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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