The concept is, I have to import excel which contains links. When we import excel, then insert multiple links into the database. How to give multiple urls using file_get_html. My code is here,
<?php if(!empty($_FILES["excel_file"])) {
$connect = mysqli_connect("localhost", "root", "", "mydb");
$file_array = explode(".", $_FILES["excel_file"]["name"]);
if($file_array[1] == "xlsx")
{
include("PHPExcel/IOFactory.php");
$output = '';
$output .= "
<label class='text-success'>Data Inserted</label>
<table class='table table-bordered'>
<tr>
<th>link</th>
</tr>
";
$object = PHPExcel_IOFactory::load($_FILES["excel_file"]["tmp_name"]);
foreach($object->getWorksheetIterator() as $worksheet)
{
$highestRow = $worksheet->getHighestRow();
for($row=2; $row<=$highestRow; $row++)
{
$link = mysqli_real_escape_string($connect, $worksheet->getCellByColumnAndRow(1, $row)->getValue());
include('simple_html_dom.php'); $html = file_get_html("$link");
foreach($html->find('table#job-content') as $article) {
$item['jobtitle'] = $article->find('b.jobtitle',0)->plaintext;
$item['companyname'] = $article->find('span.company',0)->plaintext;
$item['city'] = $article->find('span.location',0)->plaintext;
$item['job_type'] = $article->find('span.no-wrap',0)->plaintext;
$item['description'] = $article->find('td.snip',0)->plaintext;
$articles[] = $item;} $query = "INSERT INTO jobpost (jobtitle, companyname, city, job_type, description, status, employeeemail, link) VALUES ('". mysqli_real_escape_string($connect, $item['jobtitle']) ."', '". mysqli_real_escape_string($connect, $item['companyname']) ."', '". mysqli_real_escape_string($connect, $item['city']) ."', 'Full-time', '". mysqli_real_escape_string($connect, $item['description']) ."', '', 'admin@inuson.com', '$link')";
mysqli_query($connect, $query);
$output .= ' <tr> <td>'.$link.'</td> </tr> '; } $output .= '</table>'; echo $output; } else { echo '<label class="textdanger">Invalid File</label>'; } }?>
Please help me, Thanks in advance.