i have created a database called "test" and create a table called "biodata". I have created 3 columns called "Name" "Age" and "Description" into biodata table. Now how to store my array result into each column.
Below is the complete code...
<?php
$ip = "localhost";
$username = "root";
$password = "";
$dbname = "test";
$res = mysql_connect($ip,$username,$password);
if(!$res)
{
echo "DB Connection Failed.";
exit;
}
if(!mysql_select_db("test"))
{
echo "NOT SELECTED";
exit;
}
$company = array(
'Record1'=>array('Shabbir',26,'Designer'),
'Record2'=>array('Burhan',24,'Architecture'),
'Record3'=>array('Huzeifa',20,'Accountant'),
);
foreach ($company as $employees=>$details){
echo '<strong>'.$employees.'</strong><br>';
foreach($details as $employeeinfo){
echo $employeeinfo.'<br>';
}
}
$sql = "INSERT INTO biodata (Name, Age, Description) VALUES ($employeeinfo[0], $employeeinfo[1], '$employeeinfo[2]')";
mysql_query($sql);
?>