Tutorial 7 – MySQL Order By
| In: 7. Database Order By | 5,194 views
Video Tutorial
Video Source Code
File: viewContacts.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <?php // MySQL Tutorial 7 - Selecting Data From A Database With The ORDER BY keyword /* Syntax SELECT columnNames FROM tableName ORDER BY columnName(s) ASC|DESC */ include("header.php"); // include header links include("config.php"); // connect to database $result = mysql_query("SELECT * FROM contacts WHERE firstName='Sally' ORDER BY zipCode DESC") or die (mysql_error()); while ($row = mysql_fetch_array($result)) { echo "Name: $row[firstName] $row[lastName] <br>"; echo "Phone Number: $row[phoneNumber] <br>"; echo "Zip Code: $row[zipCode]"; echo "<br><br>"; } ?> |
2 Responses to Tutorial 7 – MySQL Order By
ka9584
June 12th, 2015 at 3:32 pm
mhmd
August 29th, 2016 at 7:16 am