Skip navigation
Currently Being Moderated

How do you replace one image with another

Jan 25, 2012 2:49 PM

Tags: #php #logic #image_display_from_database

I have a page that displays the results of a search for information about a club. One of the items is the club's logo. It is displayed using the following code


<img src="<?php echo $row_clubedit['club_logo_url']; ?>" alt="The Club's Logo"  class="logo" title="The Club's Logo">


This works fine, except when no club has been selected, in which case it shows the default question mark in a blue box.

It would be nice if I could display the Federation Logo, to which all the clubs belong, until a club is picked.

Is there a simple way to set a default image that would be replaced from a data set.

$row_clubedit['club_logo_url'] holds the url to the log in the format

<img src="<?php echo ( 'federation_logo_url'); ?>" alt="The Club's Logo"  class="logo" title="The Club'c Logo">


The logic I suppose would be


if club_logo_url does not exist,

          then print the  federation logo,

     else print the club logo.


How do you code that in php?

I'm only a beginner at PHP.


More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points