从BLOB数据库显示图像

时间:2014-04-28 11:12:05

标签: php database blob

我正在开发一个帖子网站...... 用户可以上传多个图像,并使用BLOB将图像存储在数据库中 现在我需要他们出现在特定的位置......

 $q = "select * from news,user WHERE N_U_id = U_id order by N_id desc";
 $res = mysql_query($q) or die(mysql_error());




 while($row = mysql_fetch_assoc($res))
  {
    $user_name = $row["U_fname"].' '.$row["U_lname"];
      $p = "select * from news_img,news WHERE I_n_id =".$row["N_id"]."";
        $imres = mysql_query($p) or die(mysql_error());
        $img_sh = "display:block";
        if(!mysql_fetch_assoc($imres))
        {
        $img_sh ='display:none';
        }


        echo '<div class="post-area">
                <div class="post-by">
                    <div class="post-by-photo-back">
                        <img class="post-by-photo" src="upload/'.$row["U_email"].'/profile photo.jpg" />
                    </div>
                    <div class="post-by-name"><a href="user/index.php?id='.$row["U_id"].'" class="post-by-name-link" >'.$user_name.'</a></div>
                </div>
                <div class="post-at">'.$row["N_date"].'</div>
                <div class="post-story">
                    <h3>'.$row["N_headline"].'</h3>

                    <div class="ps-img" style="'.$img_sh.'">
                        <!----begin------Insert to your webpage where you want to display the slider-->
                        <div class="hislider1" style="max-width:655px;  max-height:360px; margin: 0 auto;">
                        <ul style="display: none;overflow: hidden; height: 0; visibility: hidden; opacity: 0;">'
                        ;
                        while($row_img = mysql_fetch_assoc($imres)){
                        echo '
                        <li>
                        <div>
                        <img data-src="'.$imres['ng_img'].'" data-thumb-src="'.$imres['ng_img'].'" title="" alt="" data-content-type="image" data-content="" data-interval="-1"/>
                        <div data-type="effect" data-effect-type="Blur" data-duration=2000></div>
                        <div data-type="action" data-trigger-evt="" data-action-type="popUp" data-content="'.$imres['ng_img'].'"></div></div>
                        </li>';
                        }

                        echo '
                        </ul>
                    </div>
                     <!----end------Insert to your webpage where you want to display the slider-->  
                </div>
                <div class="post-story-text">
                    '.$row["N_story"].'
                </div>
                <div class="more">....Continue Reading</div>
                <div class="post-story-stuff">Tags:
                 <form>
                    <ul class="tagit ui-widget ui-widget-content ui-corner-all">
                        <li>htc-one</li>
                        <li>india</li>
                    </ul>
                </form>
                    <ul class="fb-bd">
                        <li class="fb-but">Fab !!</li>
                        <li class="bd-but">Bad ??</li>
                    </ul>
                </div>
                <div class="post-story-discuss">
                </div>
            </div>
    </div>
    ';

     }

这是我尝试但没有成功,我想如果数据库有特定N_id的图像那么只有图像的div应该出现,否则它应该被隐藏

0 个答案:

没有答案