1. Home
  2. Computing & Technology
  3. PHP / MySQL

PHP MySQL Tutorial

By Angela Bradley, About.com

5 of 5

Insert Into Tables

We can use the same method of using SQL commands to populate our database as we did to create it. Here is an example:

<?php
// Connects to your Database
mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error()); mysql_select_db("Database_Name") or die(mysql_error());
mysql_query("INSERT INTO tablename VALUES ( 'Bill', 29, 'Ford' ), ( 'Mike', 16, 'Beetle' ), ( 'Alisa', 36, 'Van' )");

Print "Your table has been populated";
?>

Index: PHP MySQL Tutorial

  1. Connect to MySQL
  2. Retrieve Data
  3. SQL Queries with PHP
  4. Create Tables
  5. Insert Into Tables

5 of 5

Explore PHP / MySQL

More from About.com

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. PHP with MySQL
  5. PHP MySQL - PHP MySQL Tutorial - Insert Into

©2008 About.com, a part of The New York Times Company.

All rights reserved.