Jump to content

Need help with a simple script I'm using....


phplacky

Recommended Posts

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

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.