insert multiple array with php in Mysql Databae step by step

Description

How to used explode function in php mysql insert values into MYSQL databse 

insert multiple array with php mysql step wise how to used for each 

for insert multiple array with php in Mysql insert multiple value and store 

array with php in Mysql DB

 

 

 

 

input array like this 

 

2-car.4-cat,5-rat,6-bat;

 

Output

 

idlist, namelist

2       car

4, cat

5,rat

6,bat

 

$staflist = $_POST['subjectstaf'];

print_r($staflist);

$array = explode(",",$staflist);

   foreach($array as $varchar){

    $arrayselect = explode("-",$varchar);

$arrayselectlist1 =  $arrayselect[0];

$arrayselectlist2 =   $arrayselect[1];

 

 echo "INSERT INTO `allstaffnlist` (`namest`, `subjectlist`, `subjectlist`) VALUES ('$batchnameliststaf', '$arrayselectlist1', '$arrayselectlist2')";  

 $addno =  mysql_query("INSERT INTO `allstaffnlist` (`namest`, `subjectlist`, `action`) VALUES ('$batchnameliststaf', '$arrayselectlist1', '$arrayselectlist2')");

 

}