gpt4 book ai didi

php - 显示来自 php 搜索的内联 html

转载 作者:行者123 更新时间:2023-11-30 00:56:52 25 4
gpt4 key购买 nike

来源可以在这里找到:results.php和邮政编码:Results zip

             <?php

// create short variable names
$searchtype=$_POST['searchtype'];

$searchterm=trim($_POST['searchterm']);

if (!$searchtype || !$searchterm) {

echo '<p><strong>You have not entered search details. Please go back and try again.</strong></p>';
exit;

}

if (!get_magic_quotes_gpc()){
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
}

@ $db = new mysqli("*","*","*","*");
if (mysqli_connect_errno()) {
echo 'Error: Could not connect to database. Please try again later.';
exit;
}

$query = "select * from acronymns where ".$searchtype." like '%".$searchterm."%' ORDER BY title ";

$result = $db->query($query);

$num_results = $result->num_rows;

echo "<p>Number of records found: ".$num_results."</p>";

for ($i=0; $i <$num_results; $i++) {
$row = $result->fetch_assoc();
echo "<p><strong>".($i+1).". ";
echo $row['acro'];
echo " - ";
echo $row['title'];
echo "</strong><br />";
echo $row['desc'];
echo "</p>";
}

// $result->free();

$db->close();

输出如下:

    • Americans with Disabilities Act (ADA)

The Americans with Disabilities Act was enacted in 1990 to establish the prohibition of discrimination on the basis of disability, which may include autism. The ADA is divided into three Titles. Title I speaks to employment law, Title II covers State and Local activities (including public transportation), and Title III relates to accommodations in public buildings and businesses.

链接为:www.ada.com target="_blank" Americans with Disabilities Act</a> (在 MySql 数据库内。

实际链接显示:http://mysiteishere.com/"www.ada.com"这当然会导致 404 错误。

提前致谢。

最佳答案

只是因为desc提交包含 URL 并不意味着它们会自动显示为 HTML 中的链接。您需要将链接输出为 href <a> 中的值元素来创建可点击的链接。您最好不要在数据库中存储完整的 HTML,而只存储链接。看来您的组合现在正在生成无效链接。简单地查看您的 HTML 源代码并修复它。

关于php - 显示来自 php 搜索的内联 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20479089/

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