How to insert multiple array in Mysql Databae php

Description

How to store array value in MySQL php. insert multiple array in Mysql Databae with php

 

Store array value in php mysql row wise, insert multiple array in column wise mysql with php 

 

 

for example = 25,24,23,2225;

$staflist = $_POST['subjectstaf'];

 

print_r($staflist);

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

foreach($array as $varchar){

    echo $varchar."<br/>";

}

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

foreach($array as $varchar){

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

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

}

Show result

namest , subjectlist

1, 14

1, 24

1, 26

1, 27

 

2nd way

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

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

namest , subjectlist

1, 14,24,26.27