The SELECT statement is used to select data from a database.
Select Data From a Database Table
The SELECT statement is used to select data from a database.
Syntax
| SELECT column_name(s)
FROM table_name |
To learn more about SQL, please visit our SQL tutorial.
To get PHP to execute the statement above we must use the mysql_query() function. This function is used to send a query or command to a MySQL connection.
Example
The following example selects all the data stored in the "Persons" table (The * character selects all the data in the table):
| "
<tr> "; while($row = mysql_fetch_array($result)) { echo ""; echo ""; echo ""; echo ""; } echo "
mysql_close($con); ?> |
The output of the code above will be:
| Firstname | Lastname |
|---|---|
| Glenn | Quagmire |
| Peter | Griffin
|
No comments:
Post a Comment