Tutorial 6 – MySQL Where
| In: 6. Database Where | 4,987 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 22 23 | <?php // MySQL Tutorial 6 - Selecting Data From A Database With The WHERE clause /* Syntax SELECT columnNames FROM tableName WHERE columnName operator value */ include("header.php"); // include header links include("config.php"); // connect to database $result = mysql_query("SELECT * FROM contacts WHERE (zipCode >= '0' AND firstName = 'Sally') AND (lastName = 'Green' OR lastName = 'Tom')") 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>"; } ?> |