Are you a PHP Programmer?. New Learner?. Then this is the correct place to learn about PHP and MySQL things.
In this post, I’m going to explain about how to create a Database and Tables respectively.
1.Probably almost all are using PhpMyAdmin. So, there is no difficult to create databases and tables!.
2. Open the PhpMyAdmin (for instance: http://localhost/phpmyadmin). The URL of your host may be different!.
3. Creating a database is so easy. see the picture below.
Type the database name in the textbox appear in the Home page of PhpMyAdmin and click “Create”. Here i typed “newtest” for example!
Now “newtest” database is available in the left side bar of the PhpMyAdmin.
4. After you create the database immediately PhpMyAdmin will ask you to enter the table name to create a Table. So easy isn’t it?!
See the above picture, Now enter a Table name and how may columns you need for the Table. Here, I enter “mytable” as a tablename and the number of fields (columns) as “3”. After you hit “Go” Button a table with three columns will be created!. See the picture below
5. Now enter the column names and set the type, See the picture below!
In the above picture, i have given “id” as first column name and set the type as “INT”. INT is nothing but Integer, Integers are numbers. “id” always be in number that’s why and see the “Index” row in the above picture there i have selected “PRIMARY” this is because “id” always should be Primary so no duplicate id will be created. Don’t forget to set the Length/Values. Here i put “3” which mean i can create 3 digit numbers. (eg. 112).
Second column as “name” and the type as “VARCHAR”. Like i said use “INT” for numbers and “VARCHAR” for Strings (words, characters etc) and give the required Length/Values. Normally for name use more than “50”,
Third Column as “date” and the type as “DATE”. The datatype “DATE” is for storing data. Always use the correct type to avoid confusion and problems!. No need to give the Length/Values here
Now Click the Save button to finish creating the table!