Jump to content

Keep 1 record at top in while loop


doddsey_65

Recommended Posts

I am creating a sticky topic feature for my forum and dont know how to keep

all topics marked sticky at the top of the list generated by the while loop. Any one have any ideas?

They are ordered by the post date column.

 

Here is the query:

 

$posts_info_query = $db->query("SELECT 
					p.post_id,
					p.topic_id,
					p.forum_id,
					p.post_poster,
					p.post_subject,
					p.post_content,
					p.post_time,
					p.post_edit_by,
					p.post_edit_date,
					p.post_edit_num,
					p.post_approved,
					p.post_quoting,
					m.user_id,
					m.user_username,
					m.user_group,
					m.user_regdate,
					m.user_birthday,
					m.user_online,
					m.user_sex,
					m.user_location,
					m.user_show_sex,
					m.user_show_location,
					m.user_show_status,
					m.user_avatar,
					m.user_sig,
					m.user_posts

					FROM ".DB_PREFIX."posts as p

					LEFT JOIN ".DB_PREFIX."members as m
					ON p.post_poster = m.user_username

					WHERE p.topic_id = '$topic_id' 

					ORDER BY p.post_time ASC

					LIMIT $start, $limit")

					or trigger_error("SQL", E_USER_ERROR);

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/218934-keep-1-record-at-top-in-while-loop/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.