Sometimes the $data[‘filename’] is null or blank. I need the img src="pdf.png" to change to a different image src="no-pdf.png" , or hide when the $data[‘filename’] is null or blank.
<table align="center" border="0" style="font-size: 14px;">
<?php
$idnum=$_POST['idnum'];
include "dbConn.php";
$records = mysqli_query($db,"select * from scan where idnum like '%$idnum%'");
while($data = mysqli_fetch_array($records))
{
?>
<tr align="center">
<td><?php echo $data['idnum']; ?> </td>
<td id="test"><a href="https://mysite.co.za/image/<?php echo $data['filename']; ?>" target="popup"
onclick="window.open('https://mysite.co.za/image/<?php echo $data['filename']; ?>','popup','width=600,height=600'); return false;">
<img src="pdf.png" style="width:30px;height:40px;"></a> </td>
</tr>
<?php
}
?>
</table>
<script>
$(document).ready(function(){
if $("#test") = "https://mysite.co.za/image/" then
$("#test").hide();
</script>
“
2
Answers
Try this.
Try like this,