You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							70 lines
						
					
					
						
							1.4 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							70 lines
						
					
					
						
							1.4 KiB
						
					
					
				| <?php | |
| 
 | |
| $DATAhst="localhost"; | |
| $DATAusr="root"; | |
| $DATApwd="root"; | |
| $DATAdtb="vds"; | |
| 
 | |
| $file = "1_NormativaELegislazione"; | |
| // $file = "2_Aerodinamica"; | |
| // $file = "3_ProntoSoccorso"; | |
| // $file = "4_FisiopatologiaDelVolo"; | |
| // $file = "5_MeteorologiaEAerologia"; | |
| // $file = "6_Strumentazione"; | |
| // $file = "7_TecnicheDiPilotaggio"; | |
| // $file = "8_Materiali"; | |
| // $file = "9_SicurezzaDelVolo"; | |
|  | |
| $conn=@mysqli_connect($DATAhst, $DATAusr, $DATApwd, $DATAdtb)or die("CONNECTION ERROR"); | |
| mysqli_set_charset($conn, "utf8"); | |
| 
 | |
| $myfile = fopen("data/".$file."RES", "r") or die("Unable to open file!"); | |
| $responses=array(); | |
| 
 | |
| while(!feof($myfile)) { | |
|   $row = explode("|",fgets($myfile)); | |
|   $responses[$row[0]] = $row[1]; | |
| } | |
| fclose($myfile); | |
| 
 | |
| 
 | |
| $myfile = fopen("data/$file", "r") or die("Unable to open file!"); | |
| $answers = array(); | |
| 
 | |
| 
 | |
| $query="DELETE FROM questions"; | |
| mysqli_query($conn,$query); | |
| 
 | |
| while(!feof($myfile)) { | |
| 
 | |
|   $row = explode("|",fgets($myfile)); | |
| 
 | |
|   if(substr($row[0], 0, 1) == "#") { | |
|     if(count($answers)) { | |
|       /* | |
|       echo $id."<br>"; | |
|       echo $title."<br>"; | |
|       echo $responses[$id]."<br>"; | |
|  | |
|       print_r($answers); | |
|       echo "<br><br>"; | |
|       */ | |
| 
 | |
|       $query="INSERT questions VALUES($id, '$title', '".serialize($answers)."', ".$responses[$id].")"; | |
|       mysqli_query($conn,$query); | |
| 
 | |
|     } | |
|     $id = substr($row[0], 1, 4); | |
|     $title = $row[1]; | |
|     $answers = []; | |
|   } else { | |
|     $answers[$row[0]] = $row[1]; | |
|   } | |
| 
 | |
| 
 | |
| } | |
| 
 | |
| 
 | |
| fclose($myfile); | |
| 
 | |
| ?>
 |