如何将lightbox jquery效果应用于从数据库中检索到的图像

时间:2013-03-02 10:50:51

标签: php database blob lightbox

Hello pal我需要一些帮助。我想在图库php文件中应用lightbox jquery效果。我正在从数据库中检索以longblob格式存储的图像。我可以通过手动提供id值来获得该效果,但是通过给出像$ id这样的变量它不提供灯箱效果....请检查以下代码并给出一些建议。

<div id="gallery">
<?php
$query = mysql_query("SELECT * FROM image_uploads") or die(mysql_error());
while($row = mysql_fetch_array($query)){
    $id = $row['entry_id'];
?>
<ul>
    <li>
        <a href="img_retrieve.php?oid=$id" $('#gallery').lightBox();">
            <img src="img_retrieve.php?sid=$id" width="72" height="72" alt="" />
        </a>
    </li>
</ul>
<?php
}
?> 
</div>

在检索页面中

if(isset($_GET['sid'])){
$id = $_GET['sid'];
$run = mysql_query("SELECT * FROM image_uploads WHERE entry_id=$id") or die(mysql_error());

    while( $images = mysql_fetch_array($run) ){
        $image = $images['s_image'];


        header("Content-type: image/jpeg");
        echo $image;
    }   
}

if(isset($_GET['oid'])){
    $id = $_GET['oid'];
    $run = mysql_query("SELECT * FROM upload_images WHERE entry_id=$id") or die(mysql_error());

    while( $images = mysql_fetch_array($run) )
        $s_image = $images['s_image'];


        header("Content-type: image/jpeg");
        echo $s_image;
    }
} 

1 个答案:

答案 0 :(得分:0)

    if(isset($_GET['sid'])){
        $id = $_GET['sid'];
        $run = mysql_query("SELECT * FROM image_uploads WHERE entry_id=$id") or die(mysql_error());

        while( $images = mysql_fetch_array($run) ){
            $image = $images['s_image'];

            header("Content-type: image/jpeg");
                echo $image;
        }   
    }

    if(isset($_GET['oid'])){
         $id = $_GET['oid'];
         $run = mysql_query("SELECT * FROM upload_images WHERE entry_id=$id") or die(mysql_error());

         while( $images = mysql_fetch_array($run) )
             $s_image = $images['s_image'];

             header("Content-type: image/jpeg");
                echo $s_image;
         }
    }