Page 1 of 1

showing links alphabatically ordered

Posted: Thu May 19, 2005 6:44 am
by crazytopu
A quick question:

My admin user (who is a completely non-tech person) is now able to insert a new link and a number of sublink under the link. My management now wants that insead of order by the sublink with sublink_id, i rather arrange their order alphabatically.

I wonder is there any php built-in function that i can use?

Posted: Thu May 19, 2005 6:48 am
by John Cartwright
You are pulling these links from a database?

Just modify your query a bit..

Code: Select all

.. ORDER BY `sublink_id`

Posted: Thu May 19, 2005 6:52 am
by crazytopu
yes, i m drawing all my links and sublinks from the database. The thing is, so far i did order their sublink_id. So, i wrote something like

Code: Select all

order by sublink_id desc;

That way, the most recent sublink were appearing at the bottom of the sublink list. But management wants that they dont want the most recent ones go at the bottom of the list, rather they want that the list is arranged alphabatically. Which i understand can't be done using a sql query alone.

Posted: Thu May 19, 2005 6:53 am
by John Cartwright

Code: Select all

.. ORDER BY `sublink_id` DESC
or

Code: Select all

.. ORDER BY `sublink_id` ASC
To reverse their order

Posted: Thu May 19, 2005 6:58 am
by crazytopu
do u understand what I am trying to say? I want to arrange all those sublinks (their title to be more precise, upon clicking which u get the body of that sublink in a separate page).

Now, i want this sublink title to be displayed alphatebatically. So, here, their ID r not playing a big role at all. Coz, i will have to fetch their title first and then arrange their order alphatically, which i understand cant be done with SQL alone.

I need a function ....is there any built-in one?

Posted: Thu May 19, 2005 8:09 am
by phpScott
why can't you order by the sublink_title in sql? Just order by the sublink_title then.

Code: Select all

.. ORDER BY `sublink_title` DESC
or

Code: Select all

.. ORDER BY `sublink_title` asc
if this isn't what you want try create a small diagram for what you want.

Posted: Fri May 20, 2005 11:40 pm
by crazytopu
Aha! thanks a lot. Indeed, I was looking for this exact solution. Stupid of me that I didnot realise that I could easily sort out any column in the database with the order by clause.

Yah, it did work :)


cheers,
Topu