I am trying to create a table and , insert some values in database with help of PHP script. While inserting only 1 row , it works fine. An when I try to enter more number of row
Use mysqli_multi_query
instead of mysqli_query
, that should do it.
$query = mysqli_multi_query($db_conx,$sqlCommand) or die(mysqli_error($db_conx));
http://php.net/manual/en/mysqli.multi-query.php
An easier approach could be to split the string with ;
and iterate of each query in the array. Execute all of them one by one..
$sqlCommandArray[]=explode(";",$sqlCommand);
for($i=0;$i<count($sqlCommandArray);$i++){
try{
mysqli_query($db_conx,$sqlCommandArray[$i]);
}
catch(Exception $ex){
echo "there was an error in executing the queries";
}
}
This would do the job without any modifications.
$query = mysqli_multi_query($db_conx,$sqlCommand);