0

我将图像存储在一列中,我只想在表格中的图像字段为空时隐藏 img 标签。

$imgResult= explode('**',$resultArray['mediaGallery']);
if(empty($imgResult)===true){
    echo "<script type=\"text/javascript\">
          $(document).ready(function(e) {
              $('.display').css('display','none');
          });
          </script>";
}
4

2 回答 2

1

我认为你应该检查if($imgResult == null)而不是empty. 因为即使您选择的表字段中没有任何内容,该变量也不会为空;它将被设置为空。

于 2012-10-08T07:55:48.943 回答
0

一种更好的方法:-

if( true == is_null( $imgResult ) ) {
}
于 2012-10-08T08:05:46.817 回答