phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


PHP MySQL: Inserting Data

Tag: mysql, database, insert, data   Category: PHP Database
post: 02 Mar 2008 read: 1,457


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:

php mysql insert data

If you see through phpmyadmin

php mysql insert data phpmyadmin


Series this article:
PHP MySQL: Connecting to Database Use mysql_connect()
PHP MySQL: Making Database Use mysql_create_db()
PHP MySQL: Making Table
PHP MySQL: The Data Type of Field
PHP MySQL: Char and Varchar Data Type
PHP MySQL: Data Type of Date
PHP MySQL: MySQL Syntax Orders
PHP MySQL: Inserting Data
PHP MySQL: Creating Form Insert Data
PHP MySQL: Display Data
PHP MySQL: mysql_fetch_row() Function
PHP MySQL: mysql_fetch_array() Function
PHP MySQL: Editing data
PHP MySQL: Deleting data
PHP MySQL: Adding Field Table
PHP MySQL: Editing Field Table
PHP MySQL: Deleting Field Table

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting