【发布时间】:2014-07-05 05:09:26
【问题描述】:
我是 PHP 新手,一直在研究基于 php 的通用搜索引擎,以便通过 MYSQL 数据库进行搜索。我已经以 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 已经位于数据库中。数据库正在向搜索引擎显示 URL,这正是我想要的,但只是希望这些 URL 可点击并链接到它们在 Google Drive 上的任何位置。我也在努力实现一个更新的 MYSQL 方法。