The Andrew N. Wiggins Consultancy

Contact me at webmaster@anw.biz

Experimental Site

 

This site designed by Byg Software Ltd

 


 
1&1 WEBHOSTING
 

 

 

 
Frequently Asked Questions Overview Search Search
Overview :: 7. Advanced functions: PHP, mySQL, perl, ssh... :: PHP ::Article #5


 

Basic phpMyAdmin Tutorial (Create / Insert / View / Delete and Querying a table)


 

 

How to create a table?
How to place data into a table?
How to query a table?
How to delete the content of a table?
How to delete a table?



How to create a table

To create a table you should go to your database using the phpMyAdmin tool
It should look similar to the following:

Create table

To create a table you should:
- Go to where it says 'Create new table on database db12345678' on the bottom of the screen.

- In the 'Name' field, type in the name of the table you wish to create. (ie. temp)

- Then type in the number of fields (number of columns) for the table you wish to create (ie. 3), in the field 'Fields'.

- Once this is done click on the Go button next to it.


You should then get something like this:

Create table 2

Here you could fill in the details you wish to have, If unsure of anything, you could leave it blank. There should be no problem.

The following must be filled however,
- The 'Field' column you should place in the attributes of the entity 'temp'. (The column names).

- The 'Type' field, you should specify what type you wish the contents to be, (i.e. an integer (INT), or a Character (CHAR), Date or time etc.) if unsure then select CHAR as this could be
used for all types (although this is not recommended for professional users).

- The 'Length Set' field, is used to specify how many characters are allowed to be placed in a database. (i.e. placing 20 for the Name attribute means that the persons name cannot be
longer than 20 characters long, if it is only the first 20 would be placed in the database).
The rest of the fields are not mandatory.

- Click on the save button.

You have now created a table.
The next page that comes up should look something like this:

Create table 3

This page is the 'property' page of the 'temp' table.




How to insert values into the table 'temp'.

 

 

Data to be inserted into the table
                            
ID Name Address

1 Jane 25 Kickler Road

 


 

To insert the data shown above in the temp table you must first
- click on the 'Insert' link in the 'property' page.(shown above).

The page that comes up will look like this:

Insert

After filling in the data in the fields provided,
- click on the Save button.

This has now entered the data into the table.



How to view the contents of your table

To view the contents of your table,
- click on the Browse link in the Properties page.

You should see something like this:

Insert 2




How to query your database using SQL

To query a database you should:
- click on your database (on the left of the screen, under 'Home').

If you wish to view the address of the person who has the ID number 1. You need to write the following SQL: select Address from temp where ID='1';

You place this in the large field on that page as shown below:
Note: You no longer place the semi-colon at the end.

Query

Once the SQL code has been placed in the text field.
- Click on the 'Go' button.

The result that you should get should be as follows:

Query Results





How to delete the contents in a table or the table itself

To delete the contents of the table, you should use the 'Empty' command.
To delete the table itself you need to use the 'Drop' command.

Drop or Empty

Please note that this will only work on the Linux Packages

TuxOnly!

 

Feedback
© 2003 1&1 WEBHOSTING