[RESOLVED] How to replace image with default image ?
I am using this code to display cd cover image and for some cds i do not have their cover pic in my db.Therefore,that feilad is empty . Is there a way in those case to put a default image such as covert does not exist image instead?
<img src="./CdImages/<?=strval( $row['visual'] );?>"
In anotherword, if <?=strval( $row['visual'] );?> produces no record replace it with for example nocd.jpg.
Re: How to replace image with default image ?
try using a IF statement to check to see a value has been set.
PHP Code:
if(strval($row['visual']) != null)
{
?>
<img src="./CdImages/<?php echo strval( $row['visual'] );?>"/>
<?
}
else
{
?>
<img src="default_image"/>
<?
}
Re: How to replace image with default image ?
you can also do that with javascript
VB Code:
<img src="./CdImages/<?=strval( $row['visual'] );?>" onError="this.src='default_image'_here">