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
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)

Link to comment
Share on other sites

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();

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.