In my php code I use a while loop as shown below.
<?php
$connection=mysqli_connect("localhost","root","","entries");
$query1="select * from jobs";
$query1exe=mysqli_query($connection,$query1);
$loopcount=0;
while($query1collector=mysqli_fetch_array($query1exe,MYSQLI_ASSOC)) {
$query2="insert into learning set name='new_1';
insert into learning set name='new_2';";
mysqli_multi_query($connection,$query2);
$loopcount++;
}
echo($loopcount);
?>
In this code I get the output as 104($loopcount) which means the loop was executed 104 times. But in my table named learning I have only two new entries new_1 and new_2. I expected 208 new entries (new_1 104 times and new_2 104 times). Why didn't I get the result expected.
I am using PHP Version 5.5.11
P.S I want to use the mysqli_multi_query itself as I need to execute a few queries simultaneously.
This is how my learning table look like when I executed my code three times
--------------------------------------------------------
slno | name | city | Phone
--------------------------------------------------------
1 | sandeep | NULL | NULL
-------------------------------------------------------
2 | new_1 | NULL | NULL
-------------------------------------------------------
3 | new_2 | NULL | NULL
-------------------------------------------------------
4 | new_1 | NULL | NULL
-------------------------------------------------------
5 | new_2 | NULL | NULL
------------------------------------------------------
6 | new_1 | NULL | NULL
------------------------------------------------------
7 | new_2 | NULL | NULL
-------------------------------------------------------
namecolumn?INSERT INTO learning (name) SELECT 'new_1' FROM jobs UNION ALL SELECT 'new_2' FROM jobsSELECT.