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

PHP MySQL Tutorial

By , About.com Guide

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";
?>

Explore PHP / MySQL
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

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

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

All rights reserved.