dongzanghui4624 2015-12-03 09:31
浏览 42
已采纳

如何在只有一次PHP时放入文本

I have a fancy-box image gallery with a border and each image has if even border-top if odd border-bottom, like this:

enter image description here

And where is the thickest border it is supposed to be text.

I have this code to every picture in the image

<?php
    $con = mysqli_connect("localhost","root","","gibellino");
    mysqli_set_charset($con,"utf-8");
    $result = mysqli_query($con, "select * from imper");
                    
    $first = 'first';
                    
    while($row = mysqli_fetch_array($result)){
        $img = $row['img'];
        echo "<a href='imagem/bd/imper/$img' rel='imper' title='$img'><img src='imagem/bd/imper/$img' alt='' id='$first'><span></span></a>";
        $first = '';
    }
    echo "<h4>Impermeabilização</h4>";
    mysqli_close($con);
?>

All the images come from the database. But as you can see there is no text and I don't know what's the problem. Has anyone worked with fancybox? And had this problem?

</div>
  • 写回答

1条回答 默认 最新

  • dongmie3987067 2015-12-03 09:45
    关注

    If you're fetching the text from the same database you're getting the $img from, you can also include the text associated with your image within the while loop. Like this...

    <?php
        $con = mysqli_connect("localhost","root","","gibellino");
        mysqli_set_charset($con,"utf-8");
        $result = mysqli_query($con, "select * from imper");
                        
        $first = 'first';
                        
        while($row = mysqli_fetch_array($result)){
            $img = $row['img'];
            echo "<a href='imagem/bd/imper/$img' rel='imper' title='$img'><img src='imagem/bd/imper/$img' alt='' id='$first'><span>$some_text</span></a>";
            $first = '';
        }
        echo "<h4>Impermeabilização</h4>";
        mysqli_close($con);
    ?>

    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?