在搜索引擎上添加“download to excel”按钮

I want to add a "download to Excel" button on a website.

I have built a search engine using PHP and mySQL.

When I search a keyword a table appears, I want this table to be

I have tried solution on this website but the data wouldn't go in the right cell! Thanks for your help!!

<?php

$dbhost = 'xxx';
$username = 'xxx';
$password = 'xxx';

mysql_connect("$dbhost" , "$username", "$password" );
mysql_select_db("Data") or die("could not find the database!");
$output = '';



if(isset($_GET['search']))
{
    $searchkey = $_GET['search'];
    $query = mysql_query("SELECT * FROM Linkedin WHERE email LIKE '%$searchkey%' ") or die("Could not search");
    $count = mysql_num_rows($query);

    if ($count == 0) 
    {
        $output = 'There was no search results !' ;

    }
    else 
    {
    echo '<table class="table table-striped table-bordered table-hover">'; 
    echo "<tr><th>Email</th><th>Hashkey</th><th>Breached account</th></tr>"; 

        while ($row = mysql_fetch_array($query))
         {


            $email = preg_replace('/(' . $searchkey . ')/i', '<mark>\1</mark>', $row["email"]);
            $hashkey = $row['hashkey'];
            echo "<tr><td>"; 
            echo $email;
            echo "</td><td>";   
            echo $hashkey;
            echo "</td><td>";
            echo "Linkedin";  
            echo "</td></tr>";  
            $output = '</table>';
        }
            echo '<div>'."$count results were found for '$searchkey'.".'</div>'.'</br>';

    }
    echo $output;
}

?>

Use jQuery datatables for the purpose. It is easy and elegant. https://datatables.net/extensions/buttons/examples/initialisation/export