This tutorial will show you how to INSERT, UPDATE, DELETE and SELECT rows from a MySQL table using PHP.
First off, this tutorial assumes you have a database connection
above all the SQL statements. The database connection should look
something like
this:
INSERT Statement:
The first statement we will look at is the INSERT statement. This is how you actually put information intno a table in the database. In this example, we will pretend like we're adding a person to a "people" table in the database. It will look like this:
php:
<?php
//these variables are used for database connection
$host = "localhost";
$user = "db_user";
$pass = "db_pass";
$database = "db_name";
//connect to the database.
$db = mysql_connect($host, $user, $pass);
mysql_select_db ($database);
?>
INSERT Statement:
The first statement we will look at is the INSERT statement. This is how you actually put information intno a table in the database. In this example, we will pretend like we're adding a person to a "people" table in the database. It will look like this: