Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <?php
- //Setto il tempo a 0 in modo tale che è infinito
- set_time_limit(0);
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "ALL_DB";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);}
- // Preparo un array vuoto
- $data = array();
- // Leggo il file in righe
- $lines = file("C:\Users\Ritel\Desktop\json\Linkedin.json");
- // Ciclo le righe
- foreach ($lines as $line) {
- // Leggo il JSON della riga
- $json = json_decode($line);
- //$array = json_decode($json, true);
- // Se il JSON è valido...
- if ($json) {
- // Aggiungo il dato all'array
- $data[] = $json;
- }
- }
- echo "<table>";
- foreach ($data as $data){
- $id = $data->id;
- $full_name = $data->full_name;
- $first_name = $data->first_name;
- $middle_initial = $data->middle_initial;
- $middle_name = $data->middle_name;
- $last_name = $data->last_name;
- $gender = $data->gender;
- $birth_year = $data->birth_year;
- $birth_date = $data->birth_date;
- $linkedin_url = $data->linkedin_url;
- $linkedin_username = $data->linkedin_username;
- $linkedin_id = $data->linkedin_id;
- $facebook_url = $data->facebook_url;
- $facebook_username = $data->facebook_username;
- $facebook_id = $data->facebook_id;
- $twitter_url = $data->twitter_url;
- $twitter_username = $data->twitter_username;
- $github_url = $data->github_url;
- $github_username = $data->github_username;
- $work_email = $data->work_email;
- $mobile_phone = $data->mobile_phone;
- $industry = $data->industry;
- $job_title = $data->job_title;
- $job_title_role = $data->job_title_role;
- $job_title_sub_role = $data->job_title_sub_role;
- $job_title_levels = $data->job_title_levels[0];
- $job_company_id = $data->job_company_id;
- $job_company_name = $data->job_company_name;
- $job_company_website = $data->job_company_website;
- $job_company_size = $data->job_company_size;
- $job_company_founded = $data->job_company_founded;
- $job_company_industry = $data->job_company_industry;
- $job_company_linkedin_url = $data->job_company_linkedin_url;
- $job_company_linkedin_id = $data->job_company_linkedin_id;
- $job_company_facebook_url = $data->job_company_facebook_url;
- $job_company_twitter_url = $data->job_company_twitter_url;
- $job_company_location_name = $data->job_company_location_name;
- $job_company_location_locality = $data->job_company_location_locality;
- $job_company_location_metro = $data->job_company_location_metro;
- $job_company_location_region = $data->job_company_location_region;
- $job_company_location_geo = $data->job_company_location_geo;
- $job_company_location_street_address = $data->job_company_location_street_address;
- $job_company_location_address_line_2 = $data->job_company_location_address_line_2;
- $job_company_location_postal_code = $data->job_company_location_postal_code;
- $job_company_location_country = $data->job_company_location_country;
- $job_company_location_continent = $data->job_company_location_continent;
- $job_last_updated = $data->job_last_updated;
- $job_start_date = $data->job_start_date;
- $job_summary = $data->job_summary;
- $location_name = $data->location_name;
- $location_locality = $data->location_locality;
- $location_metro = $data->location_metro;
- $location_region = $data->location_region;
- $location_country = $data->location_country;
- $location_continent = $data->location_continent;
- $location_street_address = $data->location_street_address;
- $location_address_line_2 = $data->location_address_line_2;
- $location_postal_code = $data->location_postal_code;
- $location_geo = $data->location_geo;
- $location_last_updated = $data->location_last_updated;
- $linkedin_connections = $data->linkedin_connections;
- $inferred_salary = $data->inferred_salary;
- $inferred_years_experience = $data->inferred_years_experience;
- $summary = $data->summary;
- $phone_numbers = $data->phone_numbers[0];
- $emails=$data->emails[0]->address;
- $emails_type=$data->emails[0]->type;
- $interests = $data->interests[0];
- $skills = $data->skills[0];
- $location_names = $data->location_names[0];
- $regions = $data->regions[0];
- $countries = $data->countries[0];
- $street_addresses = $data->street_addresses[0];
- $experience_company_name=$data->experience[0]->company->name;
- $experience_company_size = $data->experience[0]->company->size;
- $experience_company_id = $data->experience[0]->company->id;
- $experience_company_founded = $data->experience[0]->company->founded;
- $experience_company_industry = $data->experience[0]->company->industry;
- $experience_company_location = $data->experience[0]->company->location;
- $experience_company_linkedin_url = $data->experience[0]->company->linkedin_url;
- $experience_company_linkedin_id = $data->experience[0]->company->linkedin_id;
- $experience_company_facebook_url = $data->experience[0]->company->facebook_url;
- $experience_company_twitter_url = $data->experience[0]->company->twitter_url;
- $experience_company_website = $data->experience[0]->company->website;
- $experience_company_location_names = $data->experience[0]->location_names[0];
- $experience_company_end_date = $data->experience[0]->end_date;
- $experience_company_start_date= $data->experience[0]->start_date;
- $experience_company_title_name = $data->experience[0]->title->name;
- $experience_company_title_role = $data->experience[0]->title->role;
- $experience_company_title_sub_role = $data->experience[0]->title->sub_role;
- $experience_company_title_levels = $data->experience[0]->title->levels;
- $experience_company_is_primary =$data->experience[0]->is_primary;
- $experience_company_summary = $data->experience[0]->summary;
- $education_school = $data->education[0]->school;
- $education_school_end_date = $data->education[0]->end_date;
- $education_school_start_date = $data->education[0]->start_date;
- $education_school_gpa = $data->education[0]->gpa;
- $education_school_degrees = $data->education[0]->degrees[0] . ", " . $data->education[0]->degrees[1];
- $education_school_majors = $data->education[0]->majors[0];
- $education_school_minors = $data->education[0]->minors;
- $education_school_summary = $data->education[0]->summary;
- $profiles_network = $data->profiles[0]->network;
- $profiles_network_id = $data->profiles[0]->id;
- $profiles_network_url = $data->profiles[0]->url;
- $profiles_network_username = $data->profiles[0]->username;
- $sqlInsert="INSERT INTO `DB`(
- `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
- ('$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',
- '$location_address_line_2',
- '$location_postal_code',
- '$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_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[0]',
- '$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')";
- echo "<tr>";
- echo "<td>$id</td>";
- echo "<td>$first_name</td>";
- echo "<td>$last_name</td>";
- echo "<td>$full_name</td>";
- echo "</tr>";
- //Ora in SQL su PHPmyAdmin avevo fatto questa funzione per caricare il contenuto dei CSV all'interno delle Tabelle:
- if ($conn->query($sqlInsert) === TRUE) {
- echo "<b>Table linkedIn popoleted successfully</b> <br>SQL2: $sqlInsert <br><br>";
- } else {
- echo "<b>Error popoleted table linkedin: " . $conn->error . "</b><br>sqlInsert: $sqlInsert <br><br>";
- }
- }
- $conn->close();
- echo "</table>";
- echo "<br>";
- echo "<b>SQLInsert:</b>";
- echo "<br>";
- echo $sqlInsert;
- ?>
- </body>
- </html>
- RISULTATO A VIDEO:
- Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 195
- Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 238
- Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 242
- Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 243
- Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 244
- Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 245
- Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 247
- Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 262
- Warning: Undefined array key 0 in C:\xampp\htdocs\PHP7\prova.php on line 484
- Warning: Array to string conversion in C:\xampp\htdocs\PHP7\prova.php on line 493
- 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
- 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