Web Development Logs
Find articles, news and reviews about latest technologies.


Welcome Guest !
please login or register a new free account.


Home | Archives | Submit Article | Top Rated | Advance Search | Contacts Us | Rss Feeds

    Main Categories
» Free downloads
» General Blog
» Google Adsense
» Scripting languages
» Search Engines
» Web Designing

  More Options
» Most read articles
» Most rated articles

   Subscription
Subscribe now and receive free articles and updates instantly.
» Your name » Your Email

titles description    advance search
Published : April 29, 2006 | Author : Ali Roman
Category : Scripting languages | Total Views : 2120 | Rating :

  
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..



1 2 3 4 5
please rate this article     Poor
Excellent    
Most viewed articles in Scripting languages category

Retrieving data from MySQL database using php
Creating simple contact form using swishmax and php
Creating dynamic combo list with PHP and MySQL
Creating simple percentage preloader with swishmax
Saving data to a text file with swishmax and php
Most recent articles in Scripting languages category

Saving data to a text file with swishmax and php
Creating dynamic combo list with PHP and MySQL
Retrieving data from MySQL database using php
Establishing connection with MySQL using php
Creating table using MySQL database

 Visitor's Comments !

there are no comments...


    Random Pick
well not sure what to write since I am just setting the site up and posting some of my old work, but I will keep it updated. I was just working on the custom CMS which I am developing for fanslogon.com there were some minor errors...

    Statistics
» Total Articles
72
» Total Authors
96
» Total Views
116305
» Total categories
6

Delete cookies set by this site | Top   

Article Manager by Flaxweb
Copyright 2006 © Flax Article Manager v1.1