A simple example of connecting to and querying a MySQL database using PHP. There is no error checking!
5 rows returned for query SELECT * FROM jiltest ORDER BY last_name.Here's a table-oriented presentation of the data.
| id | last_name | first_name | phone |
|---|---|---|---|
| 4 | Able | Mable | 111-566-6612 |
| 3 | Doe | John | 555-658-9988 |
| 5 | Doe | Jane | 555-222-4321 |
| 2 | Jones | Quincy | 222-555-1234 |
| 1 | Smith | John | 555-258-3652 |
Here's a line-oriented presentation.
This code does not adhere to best practices!
Everyone should read and learn the mysql_XXXXX function docs at php.net.
Never allow input fields from a form to be passed to a query without taking the proper steps to defeat SQL insertion hacks! If you don't know how to do that, hit the web!