MyBB Community Forums

Full Version: Get post PID - URGENT?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have this quire:
$query = $db->query("
		SELECT p.*, p.message AS postmessage, p.subject AS postsubject, p.dateline AS postdate, t.*, t.subject AS threadsubject, u.*, f.*
		FROM ".TABLE_PREFIX."posts p  
		LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
		LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
		LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
		WHERE p.uid = '{$memprofile['uid']}'
		ORDER BY p.pid DESC
		LIMIT 0, {$postlimit}
	");

$pid = $posts['pid'];
$postlink = get_post_link($posts['pid'], $posts['tid']);

<a href=\"$postlink#pid$pid\"></a>

I am creating a plugin to show last posts in profile but for some reason post pid is wrong!

How to get post pid?
I'm assuming you have
$posts = $db->fetch_array($query)
in there somewhere right?
Thanks Paul yes I have
while($posts = $db->fetch_array($query))
May you share the full code? What hook are you using? Is {$postlimit} even defined (I guess you will get an error if not)?
@Omar G thanks you very much but I have managed to fix it!
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
Is redundant since $memprofile holds all user data.