Wednesday 15 May 2013

sql - PHP: Force 'Featured' to Top -


I have database tables with columns called "specially", which y or n .

I am trying to emphasize any 'Featured' == 'Y' to print first (this is a foreach loop ),

Right now it loads in the order of the order (id).

I tried to add specifically by ORDER at the end of my SQL query, but it does nothing

how do i Can i complete

I'm using it through a generic function. What can I do to see that "specially" what is present without 2 questions?

It breaks the SQL at that table which does not include 'Featured'

I only call it SQL To set it as necessary, set up with switch . But I would have to handle it very much in SQL statement if someone knows that thanks for helping!

Instead of using the Y and N values, 1 and 0 You can use numerical sorting like this, but if you do not really want to change your column values, then just

  specialized DESC by ORDER   

as it will put all the YS first. PS: In the future, you will find that it is better to use numbers for boolean (1 and 0), this will give you the ability to add the best features in the future, where you have the third and fourth scenario (so that you have 2 and 3, Etc.).

No comments:

Post a Comment