Click to See Complete Forum and Search --> : trying to make this page xhtml strict and one thing is buggering it.


Theremin
02-25-2007, 12:46 PM
This is the page
http://www.recordingjunkie.com/resources.php


I have this chunk of code in there.
<tr>
<td align="left">Model</td>
<td align="left">User Manual</td>
<td align="left">Datasheet</td>
<td align="left">Service Doc</td>
<td align="left">Schematic</td>
<td align="left">Doc1</td>
<td align="left">Doc2</td>
</tr>';
$bg = '#000000';
$bg =($bg =='#000000' ? '#333333' : '#333333');
echo '<tr bgcolor="' . $bg . '">

I am not entirely sure what the variable is doing. I know it switches the background color, but I don't know what the values == ? and : are affected by. So if aomeone can explain that quick and also suggest a better way of doing this function so it will pass validation. Is there a way to put this appearance function into a stylesheet and still have it change?

S! :)
Jason

NogDog
02-25-2007, 01:45 PM
echo '<tr style="background-color:' . $bg . ';">';

NogDog
02-25-2007, 01:53 PM
PS: I just took a closer look at these lines:

$bg = '#000000';
$bg =($bg =='#000000' ? '#333333' : '#333333');

They make no functional sense. The first line is simply setting the value of $bg. The second line is saying that if $bg is set to that value, then set it to '#333333' instead, otherwise set it to '#333333', which is the same (if I may state the obvious.

It looks like originally there was some intention to do some sort of color-striping of the table rows, but as written there they'll all end up with the same color of #333333. (For more information on the ?: "ternary operator", see the info on this page (http://www.php.net/ternary).)

Theremin
02-25-2007, 07:21 PM
Thx NogDog :) that answers both of my questions. I didnt understand that piece of code and you explained it. It is carry over from some suggested code that someone posted to help me with another problem. I am not striping so that also means I can take that out and put it into my style sheet and not have the error anymore :)

Thank you much.

S!
Jason

bokeh
02-26-2007, 09:00 AM
echo '<tr style="background-color:' . $bg . ';">';
Also, in my opinion that should be:
echo '<tr class="$className">';
If you leave it how it was the stylesheet designer will never be able to do his magic on it.

Theremin
02-26-2007, 12:43 PM
yeah since that function wasnt doing anything I just put it in my style sheet and am calling it like this:

echo '<tr id="restable">

btw what is the difference when using id vs class?

edit: figured it out. single vs many. so I should use class if I intend to use this in other <tr>.

thx
Jason