php execute 2 queries

Solutions on MaxInterview for php execute 2 queries by the best coders in the world

showing results for - "php execute 2 queries"
Giovanni
03 Jun 2018
1      while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
2		 {
3
4           $sql_tableone =  "INSERT into inverterlog (`id`,`timestamp`,`irradiance`,`ambienttemp`,`photovoltaictemp`,`pv1voltage`,`pv2voltage`,`pv3voltage`,`pv1current`,`pv2current`,`pv3current`,`pv1power`,`pv2power`,`pv3power`,`pv1energy`,`pv2energy`,`pv3energy`,`gridvoltagegv1`,`gridvoltagegv2`,`gridvoltagegv3`,`gridcurrentgc1`,`gridcurrentgc2`,`gridcurrentgc3`,`gridpowergp1`,`gridpowergp2`,`gridpowergp3`,`sumofapparentpower`,`gridpowertotal`,`gridenergyge1`,`gridenergyge2`,`gridenergyge3`,`socounter`,`gridcurrentdcgc1`,`gridcurrentdcgc2`,`gridcurrentdcgc3`,`gridresidualcurrent`,`gridfrequencymean`,`dcbusupper`,`dcbuslower`,`temppower`,`tempaux`,`tempctrl`,`temppower1`,`temppowerboost`,`apparentpowerap1`,`apparentpowerap2`,`apparentpowerap3`,`sovalue`,`reactivepowerrp1`,`reactivepowerrp2`,`reactivepowerrp3`,`opmode`,`latestevent`,`pla`,`reactivepowermode`,`overexcitedunderexcited`,`reactivepowerabs`,`inverter`)
5						                                  values('','$newDate','$emapData[1]','$emapData[2]','$emapData[3]','$emapData[4]','$emapData[5]','$emapData[6]','$emapData[7]','$emapData[8]','$emapData[9]','$emapData[10]','$emapData[11]','$emapData[12]','$emapData[13]','$emapData[14]','$emapData[15]','$emapData[16]','$emapData[17]','$emapData[18]','$emapData[19]','$emapData[20]','$emapData[21]','$emapData[22]','$emapData[23]','$emapData[24]','$emapData[25]','$emapData[26]','$emapData[27]','$emapData[28]','$emapData[29]','$emapData[30]','$emapData[31]','$emapData[32]','$emapData[33]','$emapData[34]','$emapData[35]','$emapData[36]','$emapData[37]','$emapData[38]','$emapData[39]','$emapData[40]','$emapData[41]','$emapData[42]','$emapData[43]','$emapData[44]','$emapData[45]','$emapData[46]','$emapData[47]','$emapData[48]','$emapData[49]','$emapData[50]','$emapData[51]','$emapData[52]','$emapData[53]','$emapData[54]','$emapData[55]','$inverter')";
6        
7		   $sql_tabletwo = "INSERT into data (`id`,`timestamp`,`gridpowertotal`,`inverter`) values ('','$newDate','$emapData[26]','$inverter')";
8         //we// are using mysql_query function. it returns a resource on true else False on error
9          
10		  $sql= $sql_tableone.";".$sql_tabletwo;
11		  
12		  $result = mysqli_multi_query( $con,$sql);
13		  
14		 if(! $result )
15			{
16				echo "<script type=\"text/javascript\">
17					alert(\"Record Insertion Failed.\");
18					</script>";
19			
20			}
21
22	
23			}
24
25         }
26         fclose($file);
27		 }
28	 
29	
30         //throws a message if data successfully imported to mysql database from excel file
31       echo "<script type=\"text/javascript\">
32					alert(\"CSV File has been successfully Imported.\");
33				window.location = \"four.php\"
34				/</script>";
35        	 
36		 
37
38		 //close of connection
39		mysqli_close($con); 
40	}
41	}
42    $result = mysqli_multi_query( $con,$sql);
43	  
44	 if(! $result )
45		{
46			echo "<script type=\"text/javascript\">
47				alert(\"multi query Record Insertion Failed.\");
48				</script>";
49		
50		}
51
52
53		}
54
55     }
56     fclose($file);
57	 }
58 
59
60     //throws a message if data successfully imported to mysql database from excel file
61   echo "<script type=\"text/javascript\">
62				alert(\"CSV File has been successfully Imported.\");
63			window.location = \"four.php\"
64			/</script>";
65    	 
66	 
67
68	 //close of connection
69	mysqli_close($con); 
70}
71}