Page 1 of 1

Displaying certain results at the top....

Posted: Wed Feb 04, 2004 6:55 pm
by Mr. Tech
I have an article script. What I am wanting to do is to display from a mysql database the "Featured articles" before the normal articles which I will order by the time they where added.

How can I do this without having to use two mysql querys? The results are also in pages.

I tried something like this:

mysql_query("select * from ".$tbl_name."_articles order by featured,uptime desc limit $vstart,$Spagecut");

Didn't work...

Posted: Wed Feb 04, 2004 8:40 pm
by DuFF
How is the articles table set up?

Posted: Wed Feb 04, 2004 8:49 pm
by Mr. Tech
What do you mean axactly?

Posted: Wed Feb 04, 2004 9:11 pm
by DuFF
In other words, what fields does it have, can you give an example row?

Ex:

Code: Select all

+-----+----------+---------+
| ID  | Article  |  Text   |
+-----+----------+---------+
|  1  | PHP Tips | blah... |
+-----+----------+---------+

Posted: Wed Feb 04, 2004 9:21 pm
by Mr. Tech

Code: Select all

id     |     title     |     cat     |     description     |     author     |     type     |     featured     |     article     |     uptime


1     |    PHP Tips      |    1     |    description here     |    My Name      |    1     |    1     |    Article text blah blah     |    1046405638
In featured, 1 means it is featured 0 or left blank means its not featured

Posted: Thu Feb 05, 2004 5:15 pm
by Mr. Tech
Is what I want possible?

Posted: Thu Feb 05, 2004 6:43 pm
by DuFF
I don't see why "order by featured,uptime" doesn't work. What happens when you do it this way?

Posted: Thu Feb 05, 2004 7:48 pm
by Mr. Tech
It puts the one that is featured down the bottom on desc and asc... is there a number i need to put in featured to make it go up the top?

Posted: Thu Feb 05, 2004 7:54 pm
by Mr. Tech
Would this work:

If it is featured, -1
If it isnt featured, 0

And then put featured,uptime desc in the quey.

It seemed to work I just want to make sure ;)