Insert Record in MySQL Table using PHPMyAdmin

In order to insert new records in table select name of the table from the database and then click on Insert link. It will display following screen.Enter values in the textbox and click on GO button as shown below:

Insert Record

As you click on GO button it will insert record in the table


Insert Record in MySQL Table using PHP Script

In order to insert records in table create InsertRecord.php file as shown below:

<Title> Insert Record</title>
<form Method="POST" Action="AddRecord.php">
<table border="1">
<td>Customer Code:</td>
<td> <input type="text" Name="Code" /></td>
<td>Customer Name:</td>
<td> <input type="text" Name="Name" /></td>
<td>Customer City:</td>
<td> <input type="text" Name="City" /></td>
<td><input type="submit" Name="submit" value="submit" /></td>

After entering information for new record in the textbox when you click on submit button you need to write script that inserts new record in the table. Create AddRecord.php file as shown below:

<? php
$Code = $_POST ['Code'];
$Name=$_POST ['Name'];
$City=$_POST ['City'];
// Establish Connection with MYSQL
$con = mysql_connect ("localhost","root");
// Select Database
mysql_select_db("DBDEMO", $con);
// Specify the query to Insert Record
$sql = "insert into Customer_Master       (CustomerCode,CustomerName,City)       values(".$Code.",'".$Name."','".$City."')";
// execute query
mysql_query ($sql,$con);
// Close The Connection
mysql_close ($con);
echo "Record Inserted Successfully";

Download Projects

Download Programs