News:

Wondering if this will always be free?  See why free is better.

Main Menu

code to get text of first post

Started by bjraines, August 21, 2008, 12:20:30 PM

Previous topic - Next topic

bjraines

can someone help me with the code to get the text of the first post only in a thread?

sawz

keep smiling, they'll always wonder what your up too.....

bjraines

not exactly , i need to know how to code it , for a custom template i am doing....

Dragooon


bjraines

the first topic

for example here someone has started a new thread

http://www.mychemistrytutor.com/forums/high-school-chemistry/quantum-mechanical-model/

i would to know the code, for this page, how to call the text of this first post.

Dragooon

#5
You can use the ID_FIRST_MSG(id_first_msg in smf 2) info in the topics table to link to the first post of the topic in messages table.
For example
SELECT t.ID_TOPIC, m.ID_MSG, m.subject, m.body
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
WHERE t.ID_FIRST_MSG = m.ID_MSG
AND t.ID_TOPIC = <your topic id>
LIMIT 1

Is in SQL query which gets the first message of a specific topic.
To get some latest topic from one board this should do
SELECT t.ID_TOPIC, m.ID_MSG, m.subject, m.body
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
WHERE t.ID_FIRST_MSG = m.ID_MSG
AND t.ID_BOARD = {your board id}
ORDER BY t.ID_TOPIC DESC
LIMIT 1

bjraines

how would i use this in the forum template to echo the topics first message?

Advertisement: