我想在每个单独的搜索结果上放置一个“阅读更多”链接,以查看完整记录。我想我需要链接到另一个文件,例如 fullview.php 。我想我可以解决-问题是如何编写代码以获取“更多”链接。
抱歉,布局/编码。我是新手:-/
<?php
$con=mysqli_connect("X", "Y", "Z") or die("Error connecting to database: ".mysqli_error());
mysqli_select_db($con,"X") or die(mysqli_error());
mysqli_query($con,"SET NAMES UTF8");
$query = $_GET['query'];
$min_length = 3;
if (strlen($query) >= $min_length) {
$query = htmlspecialchars($query);
$raw_results = mysqli_query($con,"SELECT * FROM Library WHERE (`Tablettes` LIKE '%".$query."%' OR `Title` LIKE '%".$query."%' OR `Author` LIKE '%".$query."%' OR `Language` LIKE '%".$query."%' OR `Subject` LIKE '%".$query."%' OR `Subject2` LIKE '%".$query."%' OR `Translation` LIKE '%".$query."%' OR `About` LIKE '%".$query."%') ORDER BY Lopnr ASC") or die(mysqli_error());
if (mysqli_num_rows($raw_results) > 0) {
while($results = mysqli_fetch_array($raw_results)) {
$link = '';
if (! empty($results['Link']) ) {
$link = '<em><a href='.$results['Link'].'>Follow link here</a></em>';
}
echo "<p><table bgcolor='#FFFFFF' width='900' align='center' cellpadding='3' cellspacing='0' border='0'>
<thead>
<hr align='center' width='900'>
</thead>
<tbody>
<tr>
<tr><center><font color='#ffffff'>
Library: <strong>".$results['Library']."</strong></br><tr><center>".$results['CategoryYear']."
</tr>
<tr>
<td style='border-right:none;border-left:none;border-bottom:none;border-top:none' colspan='10' valign='top'>
<em>
$link
</td>
</tr>
</tbody>
</body>
</html>
</table>";
}
} else {
echo "No results";
}
} else {
echo "Minimum length is ".$min_length;
}
?>
答案 0 :(得分:0)
您必须通过追加来定义带有库提供ID的查看更多详细文件的文件名。
例如。
$link = '<em><a href="view_library.php?id='.$results['id'].' ">Follow link here</a></em>';
这里$ results ['id']是库表的主键(我不确定您在表上设置了哪个主键)。