Show image if NULL and Category = 1
I have a recordset which shows an image. I have surrounded the code with a Show if Not Null statement meaning that I dont have a broken image showing if nothing has been displayed.
I would now like to write a statement that will show a specific image if the column is empty however the image will be different depending on the category that the article belongs too.
As an example
If image field not null show image
if image field is null and category = 1 show image A
if image field is null and category = 2 show image B
if image field is null and category = 3 show image C
if image field is null and category = 4 show image D
I was thinking of:
<?php if($row_Recordset1['newsPhoto'] != "") { ?>
<img src="../images/<?php echo $row_Recordset1['newsPhoto']; ?>" alt="<?php echo $row_Recordset1['newsTitle']; ?>" width="648" height="100" class="img-inside"/>
<?php } ?>
<?php if($row_Recordset1['newsPhoto'] = "") && ($row_Recordset1['newscat'] =1) { ?>
<img src="imageA.jpg" />
<?php } ?>
<?php if($row_Recordset1['newsPhoto'] = "") && ($row_Recordset1['newscat'] =2) { ?>
<img src="imageB.jpg" />
<?php } ?>
Would this work?
Is there a better way?
Thanks