MyBB Community Forums

Full Version: Chceck if post is thread-post
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi
How to check if post (for example pid=4) is a thread post, not replay ?
(in PHP ofc).
Thanks
Edit: Never mind I was wrong Toungue.

Edit2: Maybe take the lowest post id within that thread id.
There is no other easier way?
idk, look at how the portal.php does it Toungue.
I may be getting this confused with something else but I think there's a column in the threads table that has the first post in each thread, so you could join the threads and posts table, see if the pid you're looking at is in the column that tells you the first post in that thread, and then get the tid of that thread.
Matt's way would work, so would checking the posts table to see if replyto = 0.

For example:

$query = $db->simple_select("posts", "tid", "pid = '".$mybb->input['pid']."' AND replyto = '0'");
$thread_id = $db->fetch_field($query, "tid");

That's the way I would do it. If you wanted more info then a join is probably the only way...