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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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