[MySQL]Creating Table and Data Insertion - PHP / MySQL Tutorials
 
  Buy Ebooks, Video Games, DVDs, Electronics and more !
Home | Help Forums | Web Design Tutorials | Free Swishmax Downloads Make Money Online Blog . Free Image and Photo Sharing and Hosting

 

 

Company

Home

Nework Details

Tutorials

SWiSH 2

SWiSHMax

Flash MX

PHP & MySQL

HTML / JScript

Adobe Photoshop

Corel Draw

Gimp

Miscellaneous

Downloads

Templates

Plugins

Fonts

Wallpapers

Free Images

Scripts and Codes

Products

E-Books

SWiSH BB

SWiSH Templates

SWiSH-DB Newsletter
Subscribe to our newsletter : GO
  Partners / Affiliates

   Free image hosting
   Web Design Pakistan
   Swish Templates
   SWiSH Climax
   Talkfreelance Community
   Template Desire
   Lite boards
   Script Sector
   GimpTalk
   13dots
   Idea Designs
   PHP Cafe
   Sposatoettore
   Free swishmax templates
   Swishzone

Manage your site with Flax Article Content Management System
[MySQL]Creating Table and Data Insertion
Category : PHP / MySQL | Level : Beginner | Language : English
Ask Question | Read Comments | Post tutorial | Previous | Next

Web www.swish-db.com

This tutorial will demonstrate you how to CREATE tables and insert data into it.
I assume that you have read tutorial for mySQL connectivity and you have already made config.php Read here

Level : BEGINER

The function we will use is :
mysql_query();

For creating new tables we use the following query.
Syntax : CREATE TABLE tablename(fields)

but we have to use all queries in the function mysql_query()..
so it will be used like this.

I am making a table of members with only id,name and email.
mysql_query("CREATE TABLE members(id INT(5), name VARCHAR(20), email VARCHAR(20))");

Ok this will create table with the name members.
It was so easy, isnt it smile.gif

Now the process of inserting data into table. We will be using another query for inserting data..
Syntax : INSERT INTO tablename VALUES(fields with values)

This is how you will insert data into table. So it will be used in the fucntion like this.
mysql_query("INSERT INTO members VALUES(1,'Ali','abc@swish-db.com')");

Now if you want that ID should be unique everytime, means it cannot be the same. for example 1 is already assign to ALI so 1 cannot be entered again then you can put PRIMARY KEY in front of ID field, while you are creating table, so it will look like this,

mysql_query("CREATE TABLE members(id INT(5) PRIMARY KEY, name VARCHAR(20), email VARCHAR(20))");

so this is the basic tutorial for creating table and adding data into it. I hope it was useful.

Feel free to ask any question if you have in mind.
regards
- Ali..


© 2002-2005 Flaxweb Network | Article Manager | Gimp Tutorials Library | RAD C++ Library | Free C/C++ Sourcecode |
Sites of interest : Web Design Blog | Swish Templates | Swishmax Ebook | Photoshop Templates | Gimp Tutorials | Text Forum | Make Money Online