I wrote:

? But suppose there's a certain page where I don't want the style sheet in
? the middle - the one I named MIDDLE. Is there a way to mark it in the
? include page, then instruct the main page to either not import it or
? replace it with nothing ("")?


Luke wrote:

youd have to use a variable, so in the main page do the following

if($pagetoshow == 'withoutmiddle'){
    $includemiddle = FALSE;
}else{
    $includemiddle = TRUE; //(or false depending)
}

and in the include do this:

if($includemiddle == TRUE){
    echo '<link href="' . $periods . 'css/MIDDLE.css" rel="stylesheet"
type="text/css" />';
}




I think I just about have it. But I replaced the "middle" in both our examples with the page I'm REALLY trying to exclude - na/a1.

Most pages on my site will have the following two style sheets:

<link href="../../../../css/a1.css" rel="stylesheet" type="text/css" />
<link href="../../../../css/na/a1.css" rel="stylesheet" type="text/css"  />

But some will only have the first one:

<link href="../../../../css/a1.css" rel="stylesheet" type="text/css" />



So I applied your example to the head section of my main page and came up with this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head>
<?php
$statename = 'Alaska';
$postcode = 'ak';
$linkcode = 'world/na/us/ak';
$periods = '../../../../';
include ("../../../../includes/state/head.php");


if($pagetoshow == 'withoutna/a1'){
    $includena/a1 = FALSE;
}else{
    $includeana/a1 = TRUE; //(or false depending)
}

?>



* * * * * * * * * *

And below is all the code from the included page, head.php:

<?php
$todayDate = date("m-d-Y");
if($includeana/a1 == TRUE){
    echo '<link href="' . $periods . 'css/na/a1.css" rel="stylesheet"
type="text/css" />';
}

echo '<title>Freedomware &gt; "$statename"</title>';
echo '<meta name="description" content="ZXZX versus Microsoft" />';

echo '<script src="' . $periods . 'js/swapclass.js" type="text/javascript"></script>';

echo '<link href="' . $periods . 'css/a1.css" rel="stylesheet" type="text/css" />';
echo '<link href="' . $periods . 'css/na/a1.css" rel="stylesheet" type="text/css" />';
if($includena/a1 == TRUE){
echo '<link href="' . $periods . 'css/na/a1.css" rel="stylesheet" type="text/css" />';
}
echo '<link href="' . $periods . 'css/na/rockies.css" rel="stylesheet" type="text/css" />';
?>



I haven't been able to exclude na/a1 yet, but everything in the included page was working right up until about the end, when I did something that knocked it out of action.


Also, I got a "division by zero" error. Is that something that's caused by a mistake I made in writing code? I read a couple articles online that suggested it's a problem with Apache.

Finally, is there a way to "validate" php, similar to validating pages for html and css?




and if you are echoing a variable, quotes around it arent needed


you can just use
echo $variable;
instead of
echo "$variable";


I got a little confused; did I do it right in the example above?


Thanks!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to