如何从数据库中获取图像URL,以便当有人单击图像时,他/她可以重定向到该URL


How to get image URL from database so that when someone clicks on the image so he/she can be redirected to that URL

我已经使用URL将图像保存在数据库中。我正在做的是我正在从数据库中获取图像并在引导轮播中显示它。它工作得很好。但是我还想获取URL,以便当有人单击图像时,他/她将被重定向到与该图像链接的URL。

这是我为在滑块中显示图像所做的编码。

<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="15000">
<!-- Indicators -->
<?php
mysql_connect("localhost","twbpla5_eduardo","[2015]Honor");
mysql_select_db("twbpla5_website_dev"); 
$query = mysql_query("SELECT * FROM banner");
?>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<?php
while($row=mysql_fetch_array($query))
{
  echo '<div class="item"><img src="images/banners/'.$row[image].'" alt="'.$row[image].'"></div>';
}
?>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
</a>
</div>
<link rel="stylesheet" type="text/css" href="css/carousel.css" />
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#myCarousel .item').first().addClass('active');
$('#myCarousel').carousel();
});
</script>

我应该在上面的代码中添加什么?

尝试添加指向图像的链接:

<?php
while($row=mysql_fetch_array($query)) {
    echo '<div class="item">
              <a href="images/banners/'.$row[image].'">
                  <img src="images/banners/'.$row[image].'" alt="'.$row[image].'">
              </a>
          </div>';
}
?>

问题已解决...以下是我问题的解决方案。

<?php
while($row=mysql_fetch_array($query)) {
echo '<div class="item">
          <a href="'.$row[targetURL].'">
              <img src="images/banners/'.$row[image].'" alt="'.$row[image].'">
          </a>
      </div>';
}
?>