/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Using PHP to declare Style Sheets for frames

Hello folks…

I have spent a great deal of time now attempting to declare Style Sheets from an external .css file for frames within a website.

This is what I have achieved so far:

[url]http://theunsentletter.com/wdap/Assignment_2/[/url]

Please note the drop menu, select “Cronulla High” and press submit. You will see that all the text will become red. Please be impressed, finding the right code took me hours!

I must thank the person who created this thread:
[url]http://www.webdeveloper.com/forum/showthread.php?t=89922[/url]

However when you click on the link, the sub page does not inherit the same style sheet as the frame that linked to it. I really need all my sub pages to inherit all the styles of these three starting frames. I intend to use frames so I can easily update the website (i.e. edit links in the side column) and style sheets so visitors can select their own school colours.

I fear that the problem is I should have used Javascript all along to declare which style sheet each page should use.

If this is the case can you please suggest what sort of script/form I use?

Or, if I only need to modify the existing pages, what should I do?

I also need a way to declare the default style sheet without user interaction (I don’t want my into page to be Black and White). THus far I have no idea how!

Here are links to the frames:
[url]http://theunsentletter.com/wdap/Assignment_2/title.php[/url]
[url]http://theunsentletter.com/wdap/Assignment_2/linksColumn.php[/url]
[url]http://theunsentletter.com/wdap/Assignment_2/introPage.php[/url]
[url]http://theunsentletter.com/wdap/Assignment_2/introPage2.php[/url]

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@SheldonJun 03.2007 — Tables and iFrames? I hope that your not getting taught to use this in school.
Copy linkTweet thisAlerts:
@jesterpunchauthorJun 03.2007 — School?

University...

The lectures don't tell me much...we're pretty much on our own.

They seriously gave us a crash course in every scripting language, One week we were learning CSS, then Javascrpt the next and then it was PHP. There's not much teaching going on at all.

Can you please suggest what I should use instead?

I need a way to make a page with a title and links column that is a seperate file, and I need to be able to implement style sheets.

Please help me... You know I need assistance but instead you have just criticised what I've done!
Copy linkTweet thisAlerts:
@jesterpunchauthorJun 03.2007 — OK, I haven't managed to make DIVs work so I have stuck with tables.

However I am now using PHP inclusion and not iframes.

All in all things are looking cleaner:

http://theunsentletter.com/wdap/Assignment_2/index2.php

My problem still remains, when I select Cronulla High, everything turns red, which is good, but when you click on the link to the right, the style is lost.

Is there any way of using the selected style sheet on all the sub pages?

Or am I just crazy for using PHP to do this?

Basically what I am doing is using a submit form and the following script to define the style:

<?php $styleSheets=$_POST['styles'];?>

<link rel="stylesheet" type="text/css" href="styles/<?php print("$styleSheets");?>">

It works for the first page, but the style is lost when I click on following pages.

One way around this, I suppose, is to use an embedded PHP file for the main text (Right side) and sub-pages. However I tried this and when I clicked on the "come on in" link it filled up the parent window instead of remaining embedded in the index page... as well as losing the style.

Any feedback would be MOST appreciated!
Copy linkTweet thisAlerts:
@SheldonJun 03.2007 — What you could do is use a session.

at the start or every page put <?php session_start(); ?> before anything else.

Then when you process that select how ever you do add this
[code=php]$_SESSION['theme'] = $whatevercolorispassed;[/code]
then on each page include the session var to set the colours
Copy linkTweet thisAlerts:
@SheldonJun 03.2007 — If you post your code so far i might be able to show you.
Copy linkTweet thisAlerts:
@jesterpunchauthorJun 03.2007 — OK, here is my code...

At the moment I hope to use this layout as a template for sub-pages.

It's the "Please come on in" link that is troubling me as when I follow that link, tp a page that has the same layout as this one, the style is lost and I can't find any practical way to redefine it.

Thanks!

[code=php]<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<?php
$styleSheets=$_POST['styles'];
?>

<link rel="stylesheet" type="text/css" href="styles/<?php print("$styleSheets");?>">


</head>

<body>
<table width="700" align="left" border="0">

<tr>
<td>
<?php include('title.php');?>
</td>
</tr>
<tr valign="top">
<td width="30%">

<b>Select your school's colours:</b><br>

<form name="styles" action="index2.php" method="post">
<select name="styles">
<option value="standard.css">Standard</option>
<option value="chs.css">Cronulla High</option>
<option value="khs.css">Kirrawee High</option>
</select>
<input type="submit" value="Submit">
</form>

<br>


<?php include('linksColumn.php');?>

</td>

<td width="70%">

<b>Please <a href="index3.php" target="_self">come on in</a></b>

</td>

</tr>

</table>

</body>
</html>[/code]
Copy linkTweet thisAlerts:
@SheldonJun 03.2007 — try[code=php]<?php
session_start();

if(isset($_POST['styles'])){
$_SESSION['styles'] = $_POST['styles'];
}

?><html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="styles/<?php echo($_SESSION['styles']);?>">

</head>

<body>
<table width="700" align="left" border="0">

<tr>
<td>
<?php include('title.php');?>
</td>
</tr>
<tr valign="top">
<td width="30%">

<b>Select your school's colours:</b><br>

<form name="styles" action="index2.php" method="post">
<select name="styles">
<option value="standard.css"<?php if($_SESSION['styles'] == "standard.css"){ echo(" selected="selected" "); }?>>Standard</option>
<option value="chs.css"<?php if($_SESSION['styles'] == "chs.css"){ echo(" selected="selected" "); }?>>Cronulla High</option>
<option value="khs.css"<?php if($_SESSION['styles'] == "khs.css"){ echo(" selected="selected" "); }?>>Kirrawee High</option>
</select>
<input type="submit" value="Submit">
</form>

<br>


<?php include('linksColumn.php');?>

</td>

<td width="70%">

<b>Please <a href="index3.php" target="_self">come on in</a></b>

</td>

</tr>

</table>

</body>
</html>[/code]
Copy linkTweet thisAlerts:
@jesterpunchauthorJun 03.2007 — Thanks for your help...

I shall try this tomorrow and use the same php script for my sub-pages.

Umm... should I edit this line?

<form name="styles" action="index2.php" method="post">
Copy linkTweet thisAlerts:
@SheldonJun 04.2007 — [code=php]<form name="styles" action="<?php echo(htmlentities($_SERVER['PHP_SELF'])); ?>" method="post">[/code]
Copy linkTweet thisAlerts:
@jesterpunchauthorJun 09.2007 — Hi Sheldon,

Sorry for the late reply but THANKYOU

It worked a charm
Copy linkTweet thisAlerts:
@SheldonJun 10.2007 — Good!. Make this thread as resolved in the thread tools menu, top right.
×

Success!

Help @jesterpunch spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...