Results 1 to 3 of 3

Thread: [RESOLVED] How to replace image with default image ?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Resolved [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.
    Last edited by tony007; May 20th, 2006 at 07:58 AM.

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    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"/>
    <?
    }

  3. #3
    Fanatic Member modpluz's Avatar
    Join Date
    Sep 2005
    Location
    Lag, NG
    Posts
    633

    Re: How to replace image with default image ?

    you can also do that with javascript

    VB Code:
    1. <img src="./CdImages/<?=strval( $row['visual'] );?>" onError="this.src='default_image'_here">
    If you want the rabbit to hop, move the carrot - Paul Kellerman(Prison Break)

    onError GoTo http://vbforums.com



    My Bits:
    VB6: Change Column Name in MS ACCESS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width