LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   css question (https://www.linuxquestions.org/questions/programming-9/css-question-533821/)

rblampain 03-02-2007 03:25 AM

css question
 
Casual CSS user.
I have a small BASIC program that creates HTML scripts which all have their own CSS section between the <head></head> tags.

This CSS section includes random colours selected by the BASIC program.

These HTML scripts are then saved as a .PHP file which is called by a PHP "include" from other html.php scripts.

When these scripts created by the BASIC program are run from the console, they render properly, but when they are run from another PHP script through the "include", the colours of the first one are used for the following scripts although the rest renders properly.

It seems the <style type='text/css> .....</style> of (BASIC created) scripts are ignored starting from the second script.

The calls to these scripts are all made from within the same <table></table> in the calling script.

Could anyone tell me what could the problem be? Or am I doing something invalid?

Thank you for your help

example:

main script.php
....
<table ....><tr><td>
text
include basic made script 1
text
include basic made script 2
text
include basic made script 3
text
</td></tr></table>
....

senyahnoj 03-02-2007 04:06 AM

Can you post some of your scripts? would make it easier to understand what the problem is.

rblampain 03-02-2007 06:22 AM

Thank you for your answer.

Here is the main script, only the text has been removed.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>Title.</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel=stylesheet type="text/css" href="../css.php">
</head>
<body class="pluie">
<table class="tabl01"><tr><td align="left">
<a name="1"></a>
<h3>Title 1.</h3>
<a name="2"></a>
<h3>Title 2.</h3>
<hr class="hr4">
<a name="3"></a>
<h3>Title 3.</h3>
<a name="4"></a>
<h3>Title 4.</h3>
<a name="5"></a>
<h3>Title 5.</h3>
<?php include 'charts/p1.chart01.php'; ?>
<a name="6"></a>
<h3>Title 6</h3>
<?php include 'charts/p1.chart02.php'; ?>
<a name="7"></a>
<h3>Title 7.</h3>
<?php include 'charts/p1.chart03.php'; ?>
<a name="8"></a>
<h3>Title 8.</h3>
<a name="9"></a>
<h3>Title 9.</h3>
<hr class="hr4">
<a name="10"></a>
<h3>Title 10</h3>
</td></tr></table></body></html>

And here is the first called script (charts/p1.chart01.php), these scripts are all identical except for the text and the colour, text also removed.

<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html><head><title></title>
<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>
<style type='text/css'>
.tabl02 {
width: 100%;
border-style: solid; border-width: 20px; color: #ff99ff;
background: #99ccff;
}
.box {
border-style: solid; border-width: 10px; color: #ff33ff;
background: #00ff00;
text-align: center;
}
.narow {
width: 16px;
border-style: none;
color: #99ccff;
text-align: center;
}
.larow {
border-style: none;
color: #99ccff;
text-align: center;
}
</style>
</head><body>
<table class='tabl02'>
<tr>
<td class='larow'></td>
<td class='narow'></td>
<td class='box'><br>Text here.<br><br></td>
<td class='narow'></td>
<td class='larow'></td>
</tr><tr>
<td class='narow'></td>
<td class='narow'></td>
<td class='narow'><img src='../imag/arows/da.png'></td>
<td class='narow'></td>
<td class='narow'></td>
</tr>
<tr>
<td class='larow'></td>
<td class='narow'></td>
<td class='box'><br>Text here.<br><br></td>
<td class='narow'></td>
<td class='larow'></td>
</tr><tr>
<td class='narow'></td>
<td class='narow'><img src='../imag/arows/lda.png'></td>
<td class='narow'></td>
<td class='narow'><img src='../imag/arows/rda.png'></td>
<td class='narow'></td>
</tr>
<tr>
<td class='box'><br>Text here.<br><br></td>
<td class='narow'></td>
<td class='larow'></td>
<td class='narow'></td>
<td class='box'><br>text here.<br><br></td>
</tr></table></body></html>

senyahnoj 03-02-2007 07:26 AM

Can't replicate the problem. I took your p1.chart01.php script and saved it. Then wrote the following php script:

PHP Code:

<?
include("p1.chart01.php");
?>

It displayed it in my browser, colours and all.

Am I missing something?

cfaj 03-02-2007 07:47 AM

Quote:

Originally Posted by rblampain
Casual CSS user.
I have a small BASIC program that creates HTML scripts which all have their own CSS section between the <head></head> tags.

This CSS section includes random colours selected by the BASIC program.

These HTML scripts are then saved as a .PHP file which is called by a PHP "include" from other html.php scripts.

When these scripts created by the BASIC program are run from the console, they render properly, but when they are run from another PHP script through the "include", the colours of the first one are used for the following scripts although the rest renders properly.

It seems the <style type='text/css> .....</style> of (BASIC created) scripts are ignored starting from the second script.

The calls to these scripts are all made from within the same <table></table> in the calling script.

Could anyone tell me what could the problem be? Or am I doing something invalid?

Thank you for your help

example:

main script.php
....
<table ....><tr><td>
text
include basic made script 1
text
include basic made script 2
text
include basic made script 3
text
</td></tr></table>
....

Does the resulting page validate? Run it through the validator at validator.w3.org.

I suspect that you have <head> elements inside the <body>.

rblampain 03-02-2007 11:40 PM

Thank you for your help.

As I said in my initial questions, these scripts execute properly when run individually, the problem shows when they are called from the main script.

The first "include" always displays correctly, the second, third etc dont.

Yes, I have tried to validate the script, I get a message telling the file is of type octet but I can't figure out why.

<head></head> are before <body></body>

rblampain 03-03-2007 12:08 AM

We can ignore the main script.
Doing the following gives the same (unexpected) result.

<?
include("p1.chart01.php");
include("p1.chart02.php");
include("p1.chart03.php");
?>

I didn't think about testing it that way first.
It seems the CSS part of the scripts are ignored from the second script, in other words: the CSS part of the first scipt is applied to all scripts. There is probably a conflict between the various CSS definitions between all the scripts but my experience with CSS is not good enough to work out what it is.


All times are GMT -5. The time now is 05:44 AM.