-4

I use this query but I don't know how will I order this by DoctorName?

$q=mysqli_query($link,"Select * from doctor where status='". $stat ."'");
Alex K.
  • 171,639
  • 30
  • 264
  • 288
  • 1
    how about ORDER BY? http://www.w3schools.com/sql/sql_orderby.asp – BigScar Jun 22 '15 at 15:27
  • possible duplicate of [Sorting a MySQL query with ORDER BY or with PHP sort functions](http://stackoverflow.com/questions/3145118/sorting-a-mysql-query-with-order-by-or-with-php-sort-functions) – Jay Blanchard Jun 22 '15 at 16:27

2 Answers2

1

Add an ORDER BY statement to your query:

$q=mysqli_query($link,"Select * from doctor where status='". $stat ."' ORDER BY `doctor_last_name`");
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
0

Use the ORDER BY command to order by columns.

$q=mysqli_query($link,"Select * from doctor where status='". $stat ."' ORDER BY doctor_last_name");

You can add a list to the ORDER BY command to provide a hierarchy of order. Example:

SELECT * FROM EmployeeData ORDER BY Date, LastName, FirstName;

This command will sort by the Date column first. All matching dates will then be ordered by the LastName column. All possible records that Date AND LastName match will be ordered by the FirstName column and so on!

Ryan_W4588
  • 648
  • 3
  • 13
  • 32