Jump to content

Var Is Not Working


mightyhokie

Recommended Posts

I have a page that calls in multiple pages.

 

at the of the main page i have this code. the variable in question is $textWidth:

 

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php $titleName = "nrcert :: meet the team"; ?>
<?php  $textWidth = "700px"; ?>
<!-- STYLE SHEETS  -->
<?php include '_includes/styles.php'; ?>
<title>Welcome to the New River Center for Energy Research and Training</title>
</head>
<body>
<div class="wrapper">
 <div class="nrcertLogo"></div>
 <?php include '_includes/nav.php'; ?>
    <div class="titleArea"><?php echo $titleName; ?></div>


    <div class="contentArea"> <!--		    CONTENT AREA-->
  <?php include '_pages/training_center_team.php'; ?>
 </div>



    <?php include '_includes/footer.php'; ?>

   </div>
</body>

</html>

 

when content aria is called in the code is:

 

<div class="text_container" >
 this is where the text for this page goes
</div> <!--end text_container-->

 

which uses the php/css code:

 

<?php
header('Content-type: text/css');

 //$textWidth = "700px";

?>

.text_container{
width:<?php echo $textWidth; ?>;
height:auto;
border:#666 1px dashed;
float:left;
position:relative;
clear:none;
padding:2px;
margin-left:10px;
}

 

but for some reason the $textWidth variable from the first/main page isn't affecting the $textWidth in the .text_container style. When the page loads i want it to be width:700px; via the variable but it won't work. When i uncomment that variable in the css page it works. just not from the main page.

php_problem.zip

Link to comment
https://forums.phpfreaks.com/topic/270799-var-is-not-working/
Share on other sites

You don't say it but it looks like the CSS page is, in fact, a separate page. Which you link to using a .

Those two files are completely separate. You can't directly share variables between them.

 

Find another way to do this. One option I don't recommend is putting the width in the URL. One which I do is making different CSS files for the different layouts you have.

Link to comment
https://forums.phpfreaks.com/topic/270799-var-is-not-working/#findComment-1393040
Share on other sites

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.