Sunday, January 11, 2015

Explain how to use ORDER BY clause inside PHP Script.

ORDER BY clause in PHP is used to sort the data in the result set. It sorts data in ascending manner by default. To sort data in descending order, DESC is used.
Example:

<?php
//connect to database
mysql_select_db("my_db", $con);
//Query to list employees ordered by AGE
$result = mysql_query("SELECT * FROM Employee ORDER BY age");
?>

No comments:

Post a Comment