Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do you replace one image with another

Engaged ,
Jan 25, 2012 Jan 25, 2012

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 http://www.club.org/clublogo.png

<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.

TOPICS
Server side applications
860
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Jan 25, 2012 Jan 25, 2012

<img src="<?php echo $row_clubedit['club_logo_url'] == "" ? "http://www.club.org/clublogo.png" : $row_clubedit['club_logo_url']; ?>" alt="The Club's Logo"  class="logo" title="The Club's Logo">

should do it

Translate
Guest
Jan 25, 2012 Jan 25, 2012

<img src="<?php echo $row_clubedit['club_logo_url'] == "" ? "http://www.club.org/clublogo.png" : $row_clubedit['club_logo_url']; ?>" alt="The Club's Logo"  class="logo" title="The Club's Logo">

should do it

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 26, 2012 Jan 26, 2012
LATEST

That does indeed do the trick.

Many thanks

Howard Walker

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines