Correct code for sort Order

14 posts by 2 authors in: Forums > CMS Builder
Last Post: January 25, 2010   (RSS)

By kitka - January 15, 2010

I AM WORKING ON A REAL ESTATE WEBSITE FOR www.jodyandgeorge.com/index4.php

I created a dropdwon field for "status" of a listing that being either "For Sale" or SOLD
Currently under Order by i have the listings displaying as

featured DESC,price+0

What would i need to add to the 'ORDER BY" LINE to get the "SOLD" listings as checked from the dropdown "status" field to be displayed last
on the results page OF THE SITE
jim albert

Re: [kitka] Correct code for sort Order

By Chris - January 15, 2010

Hi kitka,

"For Sale" comes before "SOLD", alphabetically, so you can sort on that field first:

status,featured DESC,price+0

Does that help? Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Correct code for sort Order

By kitka - January 22, 2010

ok... people never give anyone break....
the client wants the lsitings to appear from Lowest price FIRST[/#000000] to highest down, then have the SOLDS appear last[/#ff0000]....
http://www.jodyandgeorge.com/index4.php
ANY IDEA WHAT THE CORRECT SYNTAX FOR THE SORT ORDER TO MAKE THIS HAPPEN WOULD BE?

The SOLD is an option from the dropdown field Status.....
The current sort order is as follows:
price+0,status,featured DESC[/#ff0000]

the dropdown list options under status are as follows:
For Sale
For Lease
For Lease or Sale
SOLD


jim albert

Re: [kitka] Correct code for sort Order

By Chris - January 22, 2010 - edited: January 22, 2010

Hi kitka,

the client wants the lsitings to appear from Lowest price FIRST to highest down, then have the SOLDS appear last....


To accomplish this, first you'll need to sort on whether or not status = "SOLD" (false will come first, since false=0 and true=1), then sort on price:

status = "SOLD", price+0

I hope this helps. Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Correct code for sort Order

By kitka - January 22, 2010

ok... the sold then is last must the price is now random... Not from lowest up?

What need to be added to the price to show the lowest number first...ie 34,000 before 123,000
jim albert

Re: [kitka] Correct code for sort Order

By Chris - January 22, 2010

Hi kitka,

Oops, you'll want "price+0" in your order by clause, not "price". I've fixed my message above to have the correct order by clause.
All the best,
Chris

Re: [kitka] Correct code for sort Order

By kitka - January 22, 2010

No it still doesn't work like that

Prices still not in order from lowest up
[/#000000]

http://www.jodyandgeorge.com/index4.php[/#000000]
jim albert

Re: [kitka] Correct code for sort Order

By kitka - January 22, 2010

It seems to be loadfing them by the address as i entered them...

If wonder if it si has to do wiht the code on the top of the list.php>

It is presently like this:

?php

require_once "init.php";

list($listingRecords, $listingDetails) = getRecords(array(
'tableName' => 'listings',
'joinTable' => 'homepages',
'perPage' => '4',

list($homepageRecords, $homepageListDetails) = getRecords(array(
'tableName' => 'homepages')
)

));

?>



Does the sort order have to appear in there somerwhere?
jim albert

Re: [kitka] Correct code for sort Order

By kitka - January 23, 2010

You rrecommended the code:
status="SOLD", price+0

It produced the solds last but the sort ordr is also now showing the rest ofd the listing as per how i entered them orginally in the admin area<

not by ascending price down...
http://www,jodyandgeorge.com/index4.php

Here a link to the admin area page that explains what is happening
http://www.jodyandgeorge.com/problemjan24.JPG
Notice the order on the index4 page and the admin page listing order...You'll see what i mean.
jim albert