06 Sep 2008 
Support Center » Knowledgebase » Web Site Related » Databases » PHP/MySQL Tutorial Pt. 2 - phpMyAdmin
 PHP/MySQL Tutorial Pt. 2 - phpMyAdmin
Solution phpMyAdmin is software used for creating and maintaining MySQL databases.

This tutorial serves to acquaint you with the very basics of phpMyAdmin through a simple exercise.

You can access your MySQL account using phpMyAdmin via the following link, but ensure that you've created an empty database first as outlined in the first part of this PHP/MySQL tutorial series.

Socrates users phpMyAdmin login
Plato users phpMyAdmin login
Athena users phpMyAdmin login
Zeno users phpMyAdmin login

When you click on the link above, a dialog box will prompt you for a username and password. This will be the username and password you specified when setting up your new database via the Control Interface.:



Once you are successfully logged in, a phpMyAdmin screen appears as shown below.



Creating a table in your database

The left-hand frame in phpMyAdmin is used for navigation, when you log in, you'll see the database you created displaying in this area. Tables will also show up under each database once they are created.

Click on the database you created in the navigation frame and a new window will appear on the right hand side.



We will now create the first table in the database, called "details". This is done by using the Create new table feature. The name of the new table is typed into the Name: field, and the number of columns in the table (4) into Fields:. Please note that when you create your own databases and tables, it's wise to plan them out carefully to allow for growth - this exercise is only meant to help you to familiarize with basic php/MySQL/phpMyAdmin functions.

After you click Go a screen similar to the following should appear. Notice that the table title will now also appear under the database name in the left hand navigation frame.



We now need to enter the names and attributes of our table fields. Enter the following information:




FieldTypeLength
idint6
namechar100
telephonechar50
birthdaychar50


The Length value indicates the maximum allowable length of characters for input. There are many different values that can be set for Type; view further documentation here. The Types specified in this example aren't the most efficient, but just used for the purposes of this exercise. The "id" field, which will be used as a Primary key for this table, has been set to auto_increment, saving you from having to having to type in the next number in sequence when you input records.

Once you've entered all the values, click Save. A screen similar to the following will appear.



You've done it - the table is now created! You'll notice that the corresponding SQL command for creating these fields is also displayed. While you don't really need to know this for the purposes of this exercise, it doesn't hurt to get familiar with the lingo over time.

Also on this page, you'll see many other options - explore these later on once you are familiar with the way everything is working.

Inserting data into the table.

Inputting data into your new table is easy. On the current screen, there's a tab labeled "Insert" - click this and another window should appear, similar to the following.



Simply type in details for each of the fields for this record. As the "id" column was specified to automatically increment, you will not need to enter a number. This number will be unique, no other record will have it and it will be added once the record is saved.

Handy Tip - if you ever get lost while getting familiar with phpMyAdmin navigation, simply click "Home" in the left hand nav bar and start again.

After you click Save, the record is saved to the details table, and the previous window we saw reappears with the SQL command for the insert. Additional records can be added by re-selecting Insert. If you are going to be inserting multiple records, you can also select the "Insert another new row" radio button on the input form.

Once you've entered a number of records into the table, you can review the records by clicking on the Browse tab. You can also select individual records for editing or deleting.



Once your database starts growing and you don't wish to flick through pages and pages of records, you can utilize the Select tab to refine displays.

Backing up your data

My first computer instructor once told me. "There are two kinds of computer users, those who have lost their data and those who are about to lose their data". While we make every effort to ensure your databases are safe and backed up regularly, you can never be too careful when it comes to backing up, so ensure you carry out the process yourself regularly.



- Click on your database name in the left hand navigation bar

- Click on EXPORT (top tab)
- Highlight the table/s you want to back up
- Select STRUCTURE and DATA radio button

- Select "Enclose table and field names with backquotes"
- Select "Save as file" and "zipped" check boxes
- Click "Go" and a zipped archive file will be generated.

What's next?

Well done! - you've created a database, a table and fields, entered in a few records, viewed the records, edited and perhaps deleted some of them and practiced backing up.

Phew! Time for a break, then to get this information displaying on your web site through the use of a query form and results display page. That will followed by another tutorial for creating an input form so you can bypass using phpMyAdmin for adding new records.


Article Details
Article ID: 68
Created On: 22 Jan 2008 11:49 PM

 This answer was helpful  This answer was not helpful

 Back
 Login [Lost Password] 
Email:
Password:
Remember Me:
 
 Search
 Article Options
Home | Submit a Ticket | Knowledgebase | Support System FAQ | ThinkUpdate
Language: