如何使页面链接显示在标题旁边?

时间:2022-06-14 01:12:39

I'm working on a search function of a flat HTML site and I've got it working but I want to add the page link to the results so people can navigate there but the page_link column won't appear next to it how can I make it appear?

我正在开发一个平面HTML网站的搜索功能,我已经开始工作,但是我想在结果中添加页面链接,以便人们可以在那里导航但是page_link列不会出现在它旁边我该怎么办?让它出现?

if(isset($_GET['keywords'])) {

$keywords = $dbc->escape_string($_GET['keywords']);

$query = $dbc->query("
    SELECT page_title
    FROM contents
    WHERE page_contents LIKE '%{$keywords}%'
    OR page_title LIKE '%{$keywords}%'
");

}
?>

<div class="result-count"> 
Found <?php echo $query->num_rows; ?> result(s).
</div>

<?php 
if($query->num_rows) {
while($r = $query->fetch_object()) {
?>
<div class="result"> 
<?php 
echo $r->page_title, $r->page_link; 
?>
</div>
<?php
}

1 个解决方案

#1


1  

  <?php 
    echo '<a href=' . $r->page_link . '>' . $r->page_title . '</a>; 
  ?>

#1


1  

  <?php 
    echo '<a href=' . $r->page_link . '>' . $r->page_title . '</a>; 
  ?>