Jump to content

display at very last page


sniperscope

Recommended Posts

Hello

I have two type of records in my MySQL database gradeA and gradeB

 

How can i display gradeB records at very last page of pagination.

 

Let me make myself clear with an example:

 

Let's say i have 20 records 12 of them is gradeA and 8 of them is gradeB

I want to display 5 records each page so,

 

Page #1 Page #2 Page #3 Page #4 Page #5

gradeA gradeA gradeA gradeB gradeB

gradeA gradeA gradeA gradeB gradeB

gradeA gradeA gradeB gradeB gradeB

gradeA gradeA gradeB gradeB gradeB

gradeA gradeA gradeB gradeB gradeB

 

I am using following mysql query but it brings me wrong order.

 

$trm = EscapeStr($_GET['shopWord']);
$sql = "SELECT s.id, s.s_name, s.s_type, s.s_area, s.d_area, s.grade, e.news_title, e.news, e.news_icon, cp.c_date 
	FROM (SELECT id, s_name, s_type, s_area, d_area, grade FROM s_master WHERE s_area LIKE '%kansai%' AND is_active = 'yes') AS s 
	LEFT JOIN (SELECT s_id, news_id, news_title, MAX(news_date) AS news, news_icon FROM news_event GROUP BY s_id ORDER BY news_id DESC) e ON s.id = e.shop_id 
	LEFT JOIN coupon cp ON s.id = cp.s_id 
	WHERE s.s_name LIKE'%" .$trm. "%'
	GROUP BY s.id 
	ORDER BY e.news DESC, s.grade ASC";
$sql_actual	= mysql_query($sql);

 

Above query gives me

 

Page #1 Page #2 Page #3 Page #4 Page #5

gradeA gradeA gradeA gradeA gradeB

gradeA gradeA gradeA gradeA gradeB

gradeA gradeA gradeA gradeA gradeB

gradeB gradeB gradeB gradeB gradeB

gradeB gradeB gradeB gradeB gradeB

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.