如果图像在使用PHP的数据表中不可用,如何隐藏字段?
我想在用户不上传图像时隐藏图像字段如果图像在使用PHP的数据表中不可用,如何隐藏字段?,php,image,Php,Image,我想在用户不上传图像时隐藏图像字段 <tr align="center"> <td><?php echo $result['id'] ?></td> <td><?php echo $result['user_id']?></td> <td><?php echo $result['username']?></td> <td
<tr align="center">
<td><?php echo $result['id'] ?></td>
<td><?php echo $result['user_id']?></td>
<td><?php echo $result['username']?></td>
<td><?php echo $result['subject']?></td>
<td>
<?
if (file_exists(public_path("images/".$result['image'].""))){
unlink(public_path("images/".$result['image']."")); {?>
<a target="_blank" href="<?php echo "images/".$result['image']."" ?>">
<img src=<?php echo "images/".$result['image'].""?>
style="height: 150px; width: 150px" /></a>
<? } } else {
echo "Image not available";
}
?>
</td>
<td><?php echo $result['question']?></td>
<td><a href="#?id=<?=$result['id']?>">
<input type="Button" name="reply" value=Reply id="reply" onclick="togglePopup()" /></a></td>
</tr>
当我点击图像时,它会将我重定向到我的图像目录。
当我点击图像时,它会在“新建”选项卡中打开(如果图像可用),如果图像不可用,它不会打开。?
请任何人帮助我。使用此代码:
<?php if(file_exists("images/".$result['image'])){ ?>
<a target="_blank" href="<?php echo "images/".$result['image']."" ?>">
<img src=<?php echo "images/".$result['image']."" ?> style="height: 150px; width: 150px" />.
</a>
<?php } else {
//
} ?>
此代码检查图像可用或没有首先您必须检查它,
$result['image']中有一个值
然后检查服务器文件中是否存在该映像(“images/”$result['image'])
如果(文件)存在(…取消链接(…
如果文件存在,你就删除它?!提示:这种HTML和PHP代码的混合让我恶心,对不起…最好在HTML之前准备带有图像标记的变量,然后把它放在HTML marckup中。关于
,戏剧也是一样。
内部
?!毫无意义此代码没有帮助。小错误:$reslut['image']
<?php if(isset($result['image']) && file_exists("images/".$result['image'])){ ?>
<a target="_blank" href="<?php echo "images/".$result['image']."" ?>">
<img src=<?php echo "images/".$result['image']."" ?> style="height: 150px; width: 150px" />.
</a>
<?php } else {
//
} ?>