phplacky Posted March 31, 2010 Share Posted March 31, 2010 I have a script that displays the text titles of each of my pages. It's linked to a shopping cart. I want to add to this script that if there is no header image or page title, it replaces itself with one default term or word, so it's not blank. I have images wrapping around it and it looks funny empty. Here is the code I am working with: if ($Header_Image) echo "<img src=\"$Header_Image\" alt=\"$pagetitle\" border=\"0\">"; else if ($pagetitle) echo "<span class=\"lgfont\">$pagetitle</span>"; Link to comment https://forums.phpfreaks.com/topic/197165-need-help-with-a-simple-script-im-using/ Share on other sites More sharing options...
the182guy Posted March 31, 2010 Share Posted March 31, 2010 What about something like this? <?php // default header image and page title $header = "default_header.jpg"; $title = "default title"; if($Header_Image) // overwrite header image if available { $header = $Header_Image; } if($pagetitle) // overwrite page title if available { $title = $pagetitle; } ?> <img src="<?php echo $header; ?>" alt="<?php echo $title; ?>" /> <span class=\"lgfont\"><?php echo $title; ?></span> Link to comment https://forums.phpfreaks.com/topic/197165-need-help-with-a-simple-script-im-using/#findComment-1034931 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.