![]() |
||||||||||||||||||
| 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 Insert IntoThe INSERT INTO statement is used to insert new records into a database table. Insert Data Into a Database TableThe INSERT INTO statement is used to add new records to a database table. Syntax
You can also specify the columns where you want to insert the data:
Note: SQL statements are not case sensitive. INSERT INTO is the same as insert into. To get PHP to execute the statements above we must use the mysql_query() function. This function is used to send a query or command to a MySQL connection. ExampleIn the previous chapter we created a table named "Person", with three columns; "Firstname", "Lastname" and "Age". We will use the same table in this example. The following example adds two new records to the "Person" table:
Insert Data From a Form Into a DatabaseNow we will create an HTML form that can be used to add new records to the "Person" table. Here is the HTML form:
When a user clicks the submit button in the HTML form in the example above, the form data is sent to "insert.php". The "insert.php" file connects to a database, and retrieves the values from the form with the PHP $_POST variables. Then, the mysql_query() function executes the INSERT INTO statement, and a new record will be added to the database table. Below is the code in the "insert.php" page:
Viewed:338
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 |
||||||||||||||||||