Jump to content

[SOLVED] php/mysql sorting confused.. help?


monkeytooth

Recommended Posts

Alright, never wanted to do this before, but now have a need, and I am sure this is a simple well hopefully simple answer. The query I go, listing it thought PHP no problem. But I want it reversed.

 

I am taking the last 10 entries and displaying them. But it displays 10-1 where as I want 1-10

 

Currently using your basic while loop to run the fetched array but how I should get it sorted is lost on me at the moment.. do I do something in the while loop to make it go 1 to 10 or do I do something the the query itself?

Link to comment
https://forums.phpfreaks.com/topic/130479-solved-phpmysql-sorting-confused-help/
Share on other sites

Ok that works but what I failed to mention but now realize is the parameters...

 

Orginal concept:

$mycrecs2z = " SELECT * FROM comp_jobs WHERE jstatus = 'active' ";
		$mycrecs2az = mysql_query($mycrecs2z) or die('1 Error, query failed<br>' . mysql_error());

 

What I have is a database with listings that are active and inactive. So i guess what I wrote orginally is kind of off.. What I need is the first 10 entries in the database that are "active" where in this database it could be 100 entries only 10 active but at diffrent places through out the 100 and can be changed at any time. to only 8 or 50 or all 100, but over all I want to list only active in this particular portion of the site, and the most recent of them sorting them so that the last entry to the database (thee most recent is first in the array)

Nevermind, answered my own question with a bit of playin around, man i feel out of it.. ever work to much on something and just.. ehhhhh.. yea..

 

anyway what worked for me was...

$mycrecs2z = " SELECT * FROM comp_jobs WHERE jstatus = 'active' ORDER BY ID DESC LIMIT 10";
		$mycrecs2az = mysql_query($mycrecs2z) or die('1 Error, query failed<br>' . mysql_error());
mysql_close();

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.