PHP MySQL: Inserting Data
php mysql basic step by step tutorial - part 8: To insert data into database, use the sintaks:
INSERT INTO nama_table (field1,field2,...) VALUES ('data1','data2',...)
If the field parameter do not declare, the amount of the inserting data must have the same as the amount of the table field.
Example:
<?
//the example of inserting data
//data_insert.php
mysql_connect("localhost","root","admin");//database connection
mysql_select_db("employees");
$order = "INSERT INTO data_employees
(name, address)
VALUES
('H.R. Dian',
'Jl. Raya Baru KOTABARU')";
//inserting data order
//declare in the order variable
$result = mysql_query($order);
if($result){
echo("<br>Input data is succeed");
}else{
echo("<br>Input data is fail");
}
?>
For the result:
If you see through phpmyadmin
