All PHP Tutorials
Ad Management
Counter
Email System
Forum and Guestbook
File Upload
Image Manipulation
Login / Members / Password
Pagination
Encode Script
Refresh / Redirection
Miscellaneous
All MySQL Tutorials
Create, Manage Database using phpMyAdmin
Connect to Database
Insert Data
Select Data
Edit Database
Update Database
Delete Database
Order Results
Forums
Home > MySQL Tutorials
Order MySQL results
Order MySQL results
In this tutorial, you'll learn how to sort MySQL result. You can sort MySQL result by ascending, descending and random MySQL result. 
 
Overview

You can order MySQL results using "ORDER BY" 1. ORDER BY column_name ASC , 2. ORDER BY column_name DESC, 3. ORDER BY RAND().

1. ORDER BY column_name ASC is order by ascending.
2. ORDER BY column_name DESC is order results by descending.
3. ORDE BY RAND() is order results by random.

If you're not set this up the default is order results by ascending.


Syntax

"SELECT column_name FROM table_name ORDER BY column_name ASC";
or
"SELECT column_name FROM table_name";
- This will select the records from mysql by ascending (ascending is the default value).


"SELECT
column_name FROM table_name ORDER BY column_name DESC";
- This will select the records from mysql by descending


"SELECT
column_name FROM table_name ORDER BY RAND()";
- This will select the records from mysql by random


Example Order by ascending
order mysql result by ascending

The records are sorted via id by ascending

Example Order by Descending
order mysql result by descending

The records are sorted via id by descending

Example Order by Random
order mysql result by random

The records are sorted by random
Random Tutorial
 
Creating simple PHP contact form
When you need user send feedback to your email you can usecontact form. In this tutorial you'll learn how to create contact form with php script.  
 
PHP Redirection script
Learn how to redirect in this tutorial, you can use header(); function in php or use meta to redirect to a new page you want or redirect to other website. 
 
   
Hosted by Hostgator
© PHPeasystep.com 2005-2008