为链接中显示的每个图像添加html链接。如何设置每个?

时间:2016-11-22 16:13:01

标签: php html

<?php
$result = $conn->query("SELECT * FROM adoption;");

if($result->num_rows !=NULL){
    while($rows = $result->fetch_assoc()){
      $AAnimalName = $rows['AAnimalName'];
        $Abreed = $rows['Abreed'];
        $Asex = $rows['Asex'];
        $Acolor = $rows['Acolor'];
        $image = $rows ['image'];
        $image_location = "admin/function/upload/".$image; ?>
        <div class="container-custom1">
        <?php
        if(file_exists($image_location )) {
    echo '<img src="'.$image_location.'" width = "248" height="190" class="age1" title>';
        }
    else {
    echo '<img src="admin/images/admin_logo.png" width="248" height="190" class="age1" title>'; } ?>

        <?php echo "<i><h1 class='junction'><a style='cursor:pointer' class='junction'>".$AAnimalName."</a></h1></i>"."<br>".$Asex." / ".$Abreed."<br>".$Acolor."<br>"?></div> 

<?php

    } }   
?>

http://imgur.com/zxXAcFF先看图片。如何添加链接,以获得有关div=container-custom

中每个图像的更多信息

1 个答案:

答案 0 :(得分:0)

将href添加到现有锚标记中。如果您已经有更多详细信息的路由设置页面只是在href中输出该路由或动态构建一个例如

#stored route in db
$url = $rows['url'];
...href="{$url}"...

#using ids from db
$id = $rows['id'];
...href="/path/to/details/{$id}"...