向MYSQL支持的PHP搜索引擎添加超链接

向MYSQL支持的PHP搜索引擎添加超链接,php,html,mysql,Php,Html,Mysql,我是PHP新手,一直在开发基于PHP的通用搜索引擎,以便通过MYSQL数据库进行搜索。我在google drive上以goo.gl格式存储了建筑物的图片。我的问题是如何为数据库中列出的url创建超链接,因为在大多数情况下,从数据库中提取链接时,链接会有所不同。有一个可点击的链接或显示图片都会很好 <html> <head> <title> Buildings</title> </head> <center> <body

我是PHP新手,一直在开发基于PHP的通用搜索引擎,以便通过MYSQL数据库进行搜索。我在google drive上以goo.gl格式存储了建筑物的图片。我的问题是如何为数据库中列出的url创建超链接,因为在大多数情况下,从数据库中提取链接时,链接会有所不同。有一个可点击的链接或显示图片都会很好

<html>
<head>
<title> Buildings</title>
</head>
<center>
<body>


<?php
include "connection.php";

$sql = "SELECT * FROM Building_Loc ";

if (isset($_POST['search'])) {

$search_term = mysql_real_escape_string($_POST['search_box']); 
$sql .= "WHERE Building LIKE '%{$search_term}%' "; 
$sql .= "OR Floor LIKE '%{$search_term}%' "; 
$sql .= "OR Number LIKE '%{$search_term}%' "; 
$sql .= "OR Building_Pictures LIKE '%{$search_term}%' ";
}   

$query = mysql_query($sql) or die(mysql_error());



?>
<form name="search_form" method="POST" action="display_data.php"> 

Search: <input type="text" name="search_box" value="" /> 
<input type="submit" name="search" value="Search">
</form>


<table width="80%" cell padding="60" cellspace="60">

<tr>
   <td><strong>Building</strong></td>            
   <td><strong>Floor</strong></td>
   <td><strong>Number</strong></td>
   <td><strong>Picture</strong></td>

</tr>
<?php while ($row = mysql_fetch_array($query)) { ?>
<tr>
   <td><?php echo $row['Building']; ?></td>              
   <td><?php echo $row['Floor']; ?></td>
   <td><?php echo $row['Number']; ?></td>       
   <td><?php echo $row['Building_Pictures']; ?></td>
</tr>

<?php } ?>

</body>
</center>
</html>

从数据库中获取URL字符串,假设我们将其放入变量$URL中,然后

超链接:

<?php echo "<a href =\"{$URL}\">Click to view</a>" ?>
图片:

<?php echo "<img src =\"{$URL}\" />" ?> 

此外,您的代码容易受到SQL注入的攻击;请参阅

您可以向我们展示您的表架构吗?您想在列表中生成指向您站点的URL的链接,以显示有关该特定建筑的详细信息?或者URL是否已在数据库中?URL已位于数据库中。数据库显示了搜索引擎的URL,这正是我想要的,但只希望这些URL可以点击并链接到Google Drive上的任何位置。我还正在努力实现一个更为最新的MYSQL方法。我将更新SQL以防止出现这种情况,但我真正的问题是,假设数据库中存储的每个URL都不同,因此每个建筑都有一个指向的不同URL,我如何将每个URL拉入PHP并使其可点击。图片存储在google drive中,URL直接指向图片。