In case of numerical values, for example the id, use
SELECT * FROM $dbtbl ORDER BY id ASC;
This will get the list of rows sort by id going up. if you now want the list the other way around, use 'ORDER BY id DESC'. ASC stands for 'Ascending' where DESC stands for 'Descending'.
In the case of letters.. This is a bit more difficult.. You'll want to use the MySQL statement 'LIKE'. This is a tool in MySQL to compare strings to strings in fields.
Basically it functions like:
SELECT * FROM $dbtbl WHERE column_name LIKE 'foo';
I tend to evade these constructions though, and go for the ORDER BY technique whereever I can.
|