spider81man

Untitled

Nov 5th, 2021
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.77 KB | None | 0 0
  1. <html>
  2. <body>
  3.  
  4. <?php
  5.  
  6. //Setto il tempo a 0 in modo tale che è infinito
  7. set_time_limit(0);
  8.  
  9. $servername = "localhost";
  10. $username = "root";
  11. $password = "";
  12. $dbname = "ALL_DB";
  13.  
  14. // Create connection
  15. $conn = new mysqli($servername, $username, $password, $dbname);
  16.  
  17. // Check connection
  18. if ($conn->connect_error) {
  19. die("Connection failed: " . $conn->connect_error);}
  20.  
  21. // Preparo un array vuoto
  22. $data = array();
  23.  
  24.  
  25. // Leggo il file in righe
  26. $lines = file("C:\Users\Ritel\Desktop\json\Linkedin.json");
  27. // Ciclo le righe
  28. foreach ($lines as $line) {
  29. // Leggo il JSON della riga
  30. $json = json_decode($line);
  31.  
  32. //$array = json_decode($json, true);
  33.  
  34. // Se il JSON è valido...
  35. if ($json) {
  36. // Aggiungo il dato all'array
  37. $data[] = $json;
  38. }
  39. }
  40.  
  41.  
  42. echo "<table>";
  43.  
  44. foreach ($data as $data){
  45. $id = $data->id;
  46. $full_name = $data->full_name;
  47. $first_name = $data->first_name;
  48. $middle_initial = $data->middle_initial;
  49. $middle_name = $data->middle_name;
  50. $last_name = $data->last_name;
  51. $gender = $data->gender;
  52. $birth_year = $data->birth_year;
  53. $birth_date = $data->birth_date;
  54. $linkedin_url = $data->linkedin_url;
  55. $linkedin_username = $data->linkedin_username;
  56. $linkedin_id = $data->linkedin_id;
  57. $facebook_url = $data->facebook_url;
  58. $facebook_username = $data->facebook_username;
  59. $facebook_id = $data->facebook_id;
  60. $twitter_url = $data->twitter_url;
  61. $twitter_username = $data->twitter_username;
  62. $github_url = $data->github_url;
  63. $github_username = $data->github_username;
  64. $work_email = $data->work_email;
  65. $mobile_phone = $data->mobile_phone;
  66. $industry = $data->industry;
  67.  
  68. $job_title = $data->job_title;
  69. $job_title_role = $data->job_title_role;
  70. $job_title_sub_role = $data->job_title_sub_role;
  71. $job_title_levels = $data->job_title_levels[0];
  72.  
  73. $job_company_id = $data->job_company_id;
  74. $job_company_name = $data->job_company_name;
  75. $job_company_website = $data->job_company_website;
  76. $job_company_size = $data->job_company_size;
  77. $job_company_founded = $data->job_company_founded;
  78. $job_company_industry = $data->job_company_industry;
  79. $job_company_linkedin_url = $data->job_company_linkedin_url;
  80. $job_company_linkedin_id = $data->job_company_linkedin_id;
  81. $job_company_facebook_url = $data->job_company_facebook_url;
  82. $job_company_twitter_url = $data->job_company_twitter_url;
  83. $job_company_location_name = $data->job_company_location_name;
  84. $job_company_location_locality = $data->job_company_location_locality;
  85. $job_company_location_metro = $data->job_company_location_metro;
  86. $job_company_location_region = $data->job_company_location_region;
  87. $job_company_location_geo = $data->job_company_location_geo;
  88. $job_company_location_street_address = $data->job_company_location_street_address;
  89. $job_company_location_address_line_2 = $data->job_company_location_address_line_2;
  90. $job_company_location_postal_code = $data->job_company_location_postal_code;
  91. $job_company_location_country = $data->job_company_location_country;
  92. $job_company_location_continent = $data->job_company_location_continent;
  93.  
  94. $job_last_updated = $data->job_last_updated;
  95. $job_start_date = $data->job_start_date;
  96. $job_summary = $data->job_summary;
  97.  
  98. $location_name = $data->location_name;
  99. $location_locality = $data->location_locality;
  100. $location_metro = $data->location_metro;
  101. $location_region = $data->location_region;
  102. $location_country = $data->location_country;
  103. $location_continent = $data->location_continent;
  104. $location_street_address = $data->location_street_address;
  105. $location_address_line_2 = $data->location_address_line_2;
  106. $location_postal_code = $data->location_postal_code;
  107. $location_geo = $data->location_geo;
  108. $location_last_updated = $data->location_last_updated;
  109. $linkedin_connections = $data->linkedin_connections;
  110. $inferred_salary = $data->inferred_salary;
  111. $inferred_years_experience = $data->inferred_years_experience;
  112. $summary = $data->summary;
  113.  
  114. $phone_numbers = $data->phone_numbers[0];
  115. $emails=$data->emails[0]->address;
  116. $emails_type=$data->emails[0]->type;
  117.  
  118. $interests = $data->interests[0];
  119. $skills = $data->skills[0];
  120. $location_names = $data->location_names[0];
  121. $regions = $data->regions[0];
  122. $countries = $data->countries[0];
  123. $street_addresses = $data->street_addresses[0];
  124.  
  125. $experience_company_name=$data->experience[0]->company->name;
  126. $experience_company_size = $data->experience[0]->company->size;
  127. $experience_company_id = $data->experience[0]->company->id;
  128. $experience_company_founded = $data->experience[0]->company->founded;
  129. $experience_company_industry = $data->experience[0]->company->industry;
  130. $experience_company_location = $data->experience[0]->company->location;
  131. $experience_company_linkedin_url = $data->experience[0]->company->linkedin_url;
  132. $experience_company_linkedin_id = $data->experience[0]->company->linkedin_id;
  133. $experience_company_facebook_url = $data->experience[0]->company->facebook_url;
  134. $experience_company_twitter_url = $data->experience[0]->company->twitter_url;
  135. $experience_company_website = $data->experience[0]->company->website;
  136.  
  137.  
  138. $experience_company_location_names = $data->experience[0]->location_names[0];
  139. $experience_company_end_date = $data->experience[0]->end_date;
  140. $experience_company_start_date= $data->experience[0]->start_date;
  141.  
  142. $experience_company_title_name = $data->experience[0]->title->name;
  143. $experience_company_title_role = $data->experience[0]->title->role;
  144. $experience_company_title_sub_role = $data->experience[0]->title->sub_role;
  145. $experience_company_title_levels = $data->experience[0]->title->levels;
  146.  
  147. $experience_company_is_primary =$data->experience[0]->is_primary;
  148. $experience_company_summary = $data->experience[0]->summary;
  149.  
  150. $education_school = $data->education[0]->school;
  151. $education_school_end_date = $data->education[0]->end_date;
  152. $education_school_start_date = $data->education[0]->start_date;
  153. $education_school_gpa = $data->education[0]->gpa;
  154. $education_school_degrees = $data->education[0]->degrees[0] . ", " . $data->education[0]->degrees[1];
  155. $education_school_majors = $data->education[0]->majors[0];
  156. $education_school_minors = $data->education[0]->minors;
  157. $education_school_summary = $data->education[0]->summary;
  158.  
  159. $profiles_network = $data->profiles[0]->network;
  160. $profiles_network_id = $data->profiles[0]->id;
  161. $profiles_network_url = $data->profiles[0]->url;
  162. $profiles_network_username = $data->profiles[0]->username;
  163.  
  164.  
  165. $sqlInsert="INSERT INTO `DB`(
  166. `id`,
  167. `full_name`,
  168. `first_name`,
  169. `middle_initial`,
  170. `middle_name`,
  171. `last_name`,
  172. `gender`,
  173. `birth_year`,
  174. `birth_date`,
  175. `linkedin_url`,
  176. `linkedin_username`,
  177. `linkedin_id`,
  178. `facebook_url`,
  179. `facebook_username`,
  180. `facebook_id`,
  181. `twitter_url`,
  182. `twitter_username`,
  183. `github_url`,
  184. `github_username`,
  185. `work_email`,
  186. `mobile_phone`,
  187. `industry`,
  188. `job_title`,
  189. `job_title_role`,
  190. `job_title_sub_role`,
  191. `job_title_levels`,
  192. `job_company_id`,
  193. `job_company_name`,
  194. `job_company_website`,
  195. `job_company_size`,
  196. `job_company_founded`,
  197. `job_company_industry`,
  198. `job_company_linkedin_url`,
  199. `job_company_linkedin_id`,
  200. `job_company_facebook_url`,
  201. `job_company_twitter_url`,
  202. `job_company_location_name`,
  203. `job_company_location_locality`,
  204. `job_company_location_metro`,
  205. `job_company_location_region`,
  206. `job_company_location_geo`,
  207. `job_company_location_street_address`,
  208. `job_company_location_address_line_2`,
  209. `job_company_location_postal_code`,
  210. `job_company_location_country`,
  211. `job_company_location_continent`,
  212. `job_last_updated`,
  213. `job_start_date`,
  214. `job_summary`,
  215. `location_name`,
  216. `location_locality`,
  217. `location_metro`,
  218. `location_region`,
  219. `location_country`,
  220. `location_continent`,
  221. `location_street_address`,
  222. `location_address_line_2`,
  223. `location_postal_code`,
  224. `location_geo`,
  225. `location_last_updated`,
  226. `linkedin_connections`,
  227. `inferred_salary`,
  228. `inferred_years_experience`,
  229. `summary`,
  230. `phone_numbers`,
  231. `emails`,
  232. `emails_type`,
  233. `interests`,
  234. `skills`,
  235. `location_names`,
  236. `regions`,
  237. `countries`,
  238. `street_addresses`,
  239. `experience_company_name`,
  240. `experience_company_size`,
  241. `experience_company_id`,
  242. `experience_company_founded`,
  243. `experience_company_industry`,
  244. `experience_company_location`,
  245. `experience_company_linkedin_url`,
  246. `experience_company_linkedin_id`,
  247. `experience_company_facebook_url`,
  248. `experience_company_twitter_url`,
  249. `experience_company_location_names`,
  250. `experience_company_end_date`,
  251. `experience_company_start_date`,
  252. `experience_company_title_name`,
  253. `experience_company_title_role`,
  254. `experience_company_title_sub_role`,
  255. `experience_company_title_levels`,
  256. `experience_company_is_primary`,
  257. `experience_company_summary`,
  258. `education_school`,
  259. `education_school_end_date`,
  260. `education_school_start_date`,
  261. `education_school_gpa`,
  262. `education_school_degrees`,
  263. `education_school_majors`,
  264. `education_school_minors`,
  265. `education_school_summary`,
  266. `profiles_network`,
  267. `profiles_network_id`,
  268. `profiles_network_url`,
  269. `profiles_network_username`)
  270. VALUES
  271. ('$id',
  272. '$full_name',
  273. '$first_name',
  274. '$middle_initial',
  275. '$middle_name',
  276. '$last_name',
  277. '$gender',
  278. '$birth_year',
  279. '$birth_date',
  280. '$linkedin_url',
  281. '$linkedin_username',
  282. '$linkedin_id',
  283. '$facebook_url',
  284. '$facebook_username',
  285. '$facebook_id',
  286. '$twitter_url',
  287. '$twitter_username',
  288. '$github_url',
  289. '$github_username',
  290. '$work_email',
  291. '$mobile_phone',
  292. '$industry',
  293. '$job_title',
  294. '$job_title_role',
  295. '$job_title_sub_role',
  296. '$job_title_levels',
  297. '$job_company_id',
  298. '$job_company_name',
  299. '$job_company_website',
  300. '$job_company_size',
  301. '$job_company_founded',
  302. '$job_company_industry',
  303. '$job_company_linkedin_url',
  304. '$job_company_linkedin_id',
  305. '$job_company_facebook_url',
  306. '$job_company_twitter_url',
  307. '$job_company_location_name',
  308. '$job_company_location_locality',
  309. '$job_company_location_metro',
  310. '$job_company_location_region',
  311. '$job_company_location_geo',
  312. '$job_company_location_street_address',
  313. '$location_address_line_2',
  314. '$location_postal_code',
  315. '$job_company_location_address_line_2',
  316.     '$job_company_location_postal_code',
  317.     '$job_company_location_country',
  318.     '$job_company_location_continent',
  319.     '$job_last_updated',
  320.     '$job_start_date',
  321.     '$job_summary',
  322.     '$location_name',
  323.     '$location_locality',
  324.     '$location_metro',
  325.     '$location_region',
  326.     '$location_country',
  327.     '$location_continent',
  328.     '$location_street_address',
  329. '$location_geo',
  330. '$location_last_updated',
  331. '$linkedin_connections',
  332. '$inferred_salary',
  333. '$inferred_years_experience',
  334. '$summary',
  335. '$phone_numbers',
  336. '$emails',
  337. '$emails_type',
  338. '$interests',
  339. '$skills',
  340. '$location_names',
  341. '$regions',
  342. '$countries',
  343. '$street_addresses',
  344. '$experience_company_name',
  345. '$experience_company_size',
  346. '$experience_company_id',
  347. '$experience_company_founded',
  348. '$experience_company_industry',
  349. '$experience_company_location',
  350. '$experience_company_linkedin_url',
  351. '$experience_company_linkedin_id',
  352. '$experience_company_facebook_url',
  353. '$experience_company_twitter_url',
  354. '$experience_company_location_names',
  355. '$experience_company_end_date',
  356. '$experience_company_start_date',
  357. '$experience_company_title_name',
  358. '$experience_company_title_role',
  359. '$experience_company_title_sub_role',
  360. '$experience_company_title_levels[0]',
  361. '$experience_company_is_primary',
  362. '$experience_company_summary',
  363. '$education_school',
  364. '$education_school_end_date',
  365. '$education_school_start_date',
  366. '$education_school_gpa',
  367. '$education_school_degrees',
  368. '$education_school_majors',
  369. '$education_school_minors',
  370. '$education_school_summary',
  371. '$profiles_network',
  372. '$profiles_network_id',
  373. '$profiles_network_url',
  374. '$profiles_network_username')";
  375. echo "<tr>";
  376. echo "<td>$id</td>";
  377. echo "<td>$first_name</td>";
  378. echo "<td>$last_name</td>";
  379. echo "<td>$full_name</td>";
  380. echo "</tr>";
  381.  
  382. //Ora in SQL su PHPmyAdmin avevo fatto questa funzione per caricare il contenuto dei CSV all'interno delle Tabelle:
  383. if ($conn->query($sqlInsert) === TRUE) {
  384. echo "<b>Table linkedIn popoleted successfully</b> <br>SQL2: $sqlInsert <br><br>";
  385. } else {
  386. echo "<b>Error popoleted table linkedin: " . $conn->error . "</b><br>sqlInsert: $sqlInsert <br><br>";
  387. }
  388. }
  389.  
  390. $conn->close();
  391. echo "</table>";
  392.  
  393. echo "<br>";
  394. echo "<b>SQLInsert:</b>";
  395. echo "<br>";
  396. echo $sqlInsert;
  397.  
  398.  
  399. ?>
  400.  
  401. </body>
  402. </html>
  403.  
  404. RISULTATO A VIDEO:
  405.  
  406. Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 195
  407.  
  408. Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 238
  409.  
  410. Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 242
  411.  
  412. Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 243
  413.  
  414. Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 244
  415.  
  416. Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 245
  417.  
  418. Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 247
  419.  
  420. Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 262
  421.  
  422. Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 484
  423.  
  424. Warning: Array to string conversion in C:\xampp\htdocs\PHP7\prova.php on line 493
  425.  
  426. Error popoleted table linkedin: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' '', '', '', '2018-12-01', '2010-09', ...' at line 152
  427.  
  428. sqlInsert: INSERT INTO `linkedin`( `id`, `full_name`, `first_name`, `middle_initial`, `middle_name`, `last_name`, `gender`, `birth_year`, `birth_date`, `linkedin_url`, `linkedin_username`, `linkedin_id`, `facebook_url`, `facebook_username`, `facebook_id`, `twitter_url`, `twitter_username`, `github_url`, `github_username`, `work_email`, `mobile_phone`, `industry`, `job_title`, `job_title_role`, `job_title_sub_role`, `job_title_levels`, `job_company_id`, `job_company_name`, `job_company_website`, `job_company_size`, `job_company_founded`, `job_company_industry`, `job_company_linkedin_url`, `job_company_linkedin_id`, `job_company_facebook_url`, `job_company_twitter_url`, `job_company_location_name`, `job_company_location_locality`, `job_company_location_metro`, `job_company_location_region`, `job_company_location_geo`, `job_company_location_street_address`, `job_company_location_address_line_2`, `job_company_location_postal_code`, `job_company_location_country`, `job_company_location_continent`, `job_last_updated`, `job_start_date`, `job_summary`, `location_name`, `location_locality`, `location_metro`, `location_region`, `location_country`, `location_continent`, `location_street_address`, `location_address_line_2`, `location_postal_code`, `location_geo`, `location_last_updated`, `linkedin_connections`, `inferred_salary`, `inferred_years_experience`, `summary`, `phone_numbers`, `emails`, `emails_type`, `interests`, `skills`, `location_names`, `regions`, `countries`, `street_addresses`, `experience_company_name`, `experience_company_size`, `experience_company_id`, `experience_company_founded`, `experience_company_industry`, `experience_company_location`, `experience_company_linkedin_url`, `experience_company_linkedin_id`, `experience_company_facebook_url`, `experience_company_twitter_url`, `experience_company_location_names`, `experience_company_end_date`, `experience_company_start_date`, `experience_company_title_name`, `experience_company_title_role`, `experience_company_title_sub_role`, `experience_company_title_levels`, `experience_company_is_primary`, `experience_company_summary`, `education_school`, `education_school_end_date`, `education_school_start_date`, `education_school_gpa`, `education_school_degrees`, `education_school_majors`, `education_school_minors`, `education_school_summary`, `profiles_network`, `profiles_network_id`, `profiles_network_url`, `profiles_network_username`) VALUES ('1', 'Pinco Palino', 'Pinco', '', '', 'Pallino', '', '', '', 'linkedin.com/in/pinco-pallino-6137b646', 'pinco-pallino-6137b646', '163224303', '', '', '', '', '', '', '', '', '', 'media production', 'communication officer', '', '', '', '', 'plan international cambodia', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '2018-12-01', '2010-09', '', 'ITALIA', '', '', '', 'ITALIA', 'EUROPA', '', '', '2018-12-01', '10', '', '6', 'Student at Department of Media and Communication', '', '[email protected]', 'personal', '', '', '', '', 'ITALIA', '', 'plan international cambodia', '', '', '', '', '', '', '', '', '', '', '', '2010-09', 'communication officer', '', '', '', '1', '', '', '2014', '2010', '', 'bachelors, bachelor of arts', 'media management', 'Array', '', 'linkedin', '163224303', 'linkedin.com/in/pinco-pallino-6137b646', 'pinco-pallino-6137b646')
Advertisement
Add Comment
Please, Sign In to add comment