Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 加上「;下载至excel“;搜索引擎上的按钮_Php_Mysql_Excel - Fatal编程技术网

Php 加上「;下载至excel“;搜索引擎上的按钮

Php 加上「;下载至excel“;搜索引擎上的按钮,php,mysql,excel,Php,Mysql,Excel,我想在网站上添加“下载到Excel”按钮 我用PHP和mySQL构建了一个搜索引擎 当我搜索关键字时,会出现一个表,我希望该表 我已经在这个网站上尝试了这个解决方案,但是数据不会进入正确的单元格! 谢谢你的帮助 <?php $dbhost = 'xxx'; $username = 'xxx'; $password = 'xxx'; mysql_connect("$dbhost" , "$username", "$password" ); mysql_select_db("Data")

我想在网站上添加“下载到Excel”按钮

我用PHP和mySQL构建了一个搜索引擎

当我搜索关键字时,会出现一个表,我希望该表

我已经在这个网站上尝试了这个解决方案,但是数据不会进入正确的单元格! 谢谢你的帮助

<?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;
}

?>

为此使用jQuery数据表。它简单而优雅。
$output=''行是多余的,结束标记应在
之前打印。否则,请解释
数据不在正确单元格中的含义。