Forum Moderators: coopster
I have a table that is created via while loop, within the lopp is some info that is calculated and extracted from a db and used later on in the script, the issue i have is using some of this detail to change the background color of a table cell. here is the pesudo script type thingy to show ordering
while(records in db create the following){
<td>
while(another check is performed to extract and obtain more info){
within this while loop is the data i need to drive the <td bgcolor change> in the encapulating while loop.
}
}
I cannot move the <td> into the other while loop as it messes up the table structure. I am unsure how to change the td bgcolor because of the scripts order of execution. Has anyone got any ideas, i was thinking about stretching out the <td> but i do echo other things to screen inbetween the 2 points which would appear in the <td> and the while lopp would be an issue as well. is it possible to define the cells background color outside of the td tags?
background-color: black;
color: white;
}
.tableBG2{
background-color: white;
color: black;
}
you can format those tags however you want
Now in your php
while(records in db create the following){
<td>
while(another check is performed to extract and obtain more info){
if(your first check){
echo("<td class = 'tableBG1'>Some output</td>");
}//if
else{
echo("<td class = 'tableBG2'>Some output</td>");
}//else
}
If you want more detailed instructions post your code and ill edit it for you
echo "<script type=\"text/javascript\" language=\"javascript\">document.getElementById(id_here).style.backgroundColor = "yellow"</script>";
Something like that would work if the id's were assigned properly.
$output = '';
while(records in db create the following){
$record = '';
$record .= 'something';
while(another check is performed to extract and obtain more info){
$record .= 'something else';
$colour = 'blue';
}
$record = "<td style='color: $colour'>$record";
$output .= $record;
}
echo $output;