This is a tutorial written by FarooqAzam from Betlik.com
This tutorial is for Connecting,Inserting Data,Selecting and Showing Data from mysql database. So lets begin

Step 1: Connecting.
----------------------------------------------------------------
First of all open your editor, i use Dreamweaver and also suggest you to use it. Run apache. Make a new file "config.php" and add the following code:-
PHP Code:
<?php
// Declare some variables
$host = "your host";
$username = "Database username";
$password = "Databse password";
$db = "Database Name";
// Connecting
$conn = @mysql_connect($host,$username,$password);
// If mysql connecting doesnt work
if(!$connection) {
// Then show the following text
exit("Can not connect to MySQL");
}
// If Mysqldatabase doesn't exist or if any errors then
if(!@mysql_select_db($db,$conn ) {
// Show the following text:
exit("Can not select the MySQL DB");
}
?>
Save the file as "config.php"
Step 2: Inserting Data
--------------------------------------------------
Make a file and name it "forms.php" and insert the following html code:-
HTML Code:
<html>
<head>
<title>Forms</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="insert.php">
<p>Name:-<br>
<input name="name" type="text" id="name">
<br>
<br>
Age:-<br>
<input name="age" type="text" id="age">
<br>
<br>
<input type="submit" name="Submit">
</p>
</form>
</body>
</html>
In "forms.php" when you add the html code you will see two text fields and a submit button.
Ok, now make another file "insert.php" and add the following code:-
PHP Code:
<?php
// Include the Mysql Connecting file (config.php)
include "config.php"
$name = $_POST['name'];
$age = $_POST['age'];
//Insert into Mysql Database:
mysql_query("INSERT INTO tablename (name,age) VALUES( " . $name . ", " . $age . ")");
// Show a alert when data inserted to Mysql.
echo "<script language=javascript>alert('Data inserted to Mysql Databse!'); window.location = 'forms.php'; </script>";
?>
Selecting and Showing Data From Mysql Databse:-
----------------------------------------------------------------
First of all, make a new file and name it "index.php" and add the following code:-
PHP Code:
<?php
// Include Mysql Connecting file (config.php)
include "config.php";
// Selecting data from Database:
// Tip: Asteric (*) is used to select all the rows in the table name.
$result = mysql_query("SELECT * FROM tablename");
while ($show = mysql_fetch_array($result)) {
// Write the Name and Age inserted into Mysql Database
echo "Name: " . $show['name'];
echo "Age: " . $show['age'];
}
?>
Tutorial Done!
If you have any questions don't hesitate to ask
Thanks