gpt4 book ai didi

php - 在搜索引擎上添加 "download to excel"按钮

转载 作者:行者123 更新时间:2023-11-29 05:07:44 25 4
gpt4 key购买 nike

我想在网站上添加一个“下载到 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 数据表。它简单而优雅。 https://datatables.net/extensions/buttons/examples/initialisation/export

关于php - 在搜索引擎上添加 "download to excel"按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45056624/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com