Leakbali
w3 Tutorial, Web Tutorial
Register   Login
Share

Inserting Data Into Table 


When data is put into a MySQL table it is referred to as inserting data. When inserting data it is important to remember the exact names and types of the table's columns. If you try to place a 500 word essay into a column that only accepts integers of size three, you will end up with a nasty error!

Now that you have created your table, let's put some data into that puppy! Here is the PHP/MySQL code for inserting data into the "example" table we created in the previous lesson.

PHP & MySQL Code

<?php
// Make a MySQL Connection
mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());

// Insert a row of information into the table "example"
mysql_query("INSERT INTO example 
(name, age) VALUES('Putu Sanjaya', '23' ) ") 
or die(mysql_error());  

mysql_query("INSERT INTO example 
(name, age) VALUES('Made Sanjaya', '21' ) ") 
or die(mysql_error());  

mysql_query("INSERT INTO example 
(name, age) VALUES('Nyoman Sanjaya', '15' ) ") 
or die(mysql_error());  

echo "Data Inserted!";

?>

Display

Data Inserted!
More Tutorial
  1. MYSQL - Inserting Data Into Table
  2. MYSQL - Insert Data Explanation

References

About Us

Home
About Us
Contact Us
Sitemap

Tools

Google PageRank
Alexa Rank
Keywords Density

Accounts

Register Account
Login
Valid XHTML 1.0 TransitionalValid CSS!
Web Directory


2006 - 2012 © Leakbali.com - Free Web Tutorial, Free Web Articles, Web Sharing, Source Codes, Web References