![]() |
|||||||||||||||||||||||
| Home --- Topics --- Articles --- Offers --- Register --- Contact us | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
|
Did you know? if you register at Hamid School you can save up to 45% on hosting packages offered by Surreyhost.com . Don't miss out, every minute counts! Are you Confused? Click here to learn how to use hamid school PHP MySQL SelectThe SELECT statement is used to select data from a database. Select Data From a Database TableThe SELECT statement is used to select data from a database. Syntax
Note: SQL statements are not case sensitive. SELECT is the same as select. 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. ExampleThe following example selects all the data stored in the "Person" table (The * character selects all of the data in the table):
The example above stores the data returned by the mysql_query() function in the $result variable. Next, we use the mysql_fetch_array() function to return the first row from the recordset as an array. Each subsequent call to mysql_fetch_array() returns the next row in the recordset. The while loop loops through all the records in the recordset. To print the value of each row, we use the PHP $row variable ($row['FirstName'] and $row['LastName']). The output of the code above will be:
Display the Result in an HTML TableThe following example selects the same data as the example above, but will display the data in an HTML table:
The output of the code above will be:
Viewed:379 Original Author: W3school however, some changes have been made to the main contents.
Did you know? if you register at Hamid School you can learn web programming and designing for free and also you can save up to 45% on hosting packages offered by Surreyhost.com . Don't miss out, every minute counts!
|
|
||||||||||||||||||||||
|
Sponsored by: Surreyhost.com Coded and designed by: Hamid Moudi HPLA Follow us: ![]() ![]() |
|||||||||||||||||||||||