PHP mysqli ORDER BY clause - Web Development

PHP mysqli ORDER BY clause

I will show you how to use ORDER BY clause in PHP . I have used select query to show database data on the table .The ORDER BY lets you define the field name in ascending or descending order .

This is our ORDER BY Query :-


This would be your database table in your db – Database name : test

Please make this same table in your database with name users

idname ageemail
1Dheeraj29[email protected]
2Baljeet35[email protected]
3Shubhangi27[email protected]

Now below is our code , I have used mysqli procedural method . As you know there are 3 methods – > Msqli OOP , PDO & Mysqli Procedural

Your output will be this ( I have used DESC show data will show in descending order )

The name is in DESCEDING order because i have used DESC in query and you can use ASC .

Leave a Reply

Your email address will not be published. Required fields are marked *