PHP Tutorial: MySQL

PHP Tutorial: MySQL thumbnail
PHP Tutorial: MySQL

MySQL is an open source database. SQL, or Structured Query Language, is the language used to create, query and manipulate MySQL databases. The server-side scripting language, PHP, in conjunction with MySQL, can create dynamic web pages.

  1. Getting Started

    • Before using MySQL, you should have basic knowledge of PHP and understand that MySQL is a relational database management system where data is stored in tables.

    PHP and MySQL

    • PHP can call MySQL functions that connect with or manipulate the database, such as the function mysql_connect($dbhost, $dbuser, $dbpass) where parameter $dbhost = the host server, $dbuser = your username and $dbpass = the password that allows access to the database.

    Create Database

    • Usually, you create your database through your host's tools; assign a user with a password so that a user can add tables to it.

    Tables

    • Example of a Table Filled with Data.

      Tables will contain data arranged in a logical fashion and you can create one with the following syntax:
      Example: mysql>CREATE TABLE table_name (column1_name datatype, column2_name datatype, column3_name datatype);

    Querying Database

    • Once you populate your tables by either loading data from a file or using the INSERT statement to add one record at a time, you can retrieve the data with the syntax:
      SELECT what information to select
      FROM name of table(s)
      WHERE conditions;

Related Searches:

References

Resources

  • Photo Credit Jennifer M. Graham

Comments

You May Also Like

Related Ads

Featured