Hey all,
i have a problem with some code, what im trying to create is a color coded percentage.
so i fill in a field in a database with a number as a %'age of what i have done.
if its under 25% then the color is red under 50 it is orange under 75 it is yellow and 100 is green for file finished.
Now, in the code i have it pull the info out from the database and show it in a list so visitors can see how the files are coming along.
now everything was fine untill i added the code for the colors and if they were under or over a certain %'age, now it repeats the info in the database 8 times and the very last set has the right colors.
so it repeats everythin 7 times and on the 8th time it has the right colors for the right %'age.
Can anyone help me fix this code so that it will only show it once and not 8 times.
Thanks
Rich.
<link rel="stylesheet" type="text/css" href="stylenews.css">
<?
include('data.php');
//include("funktioner.php");
mysql_connect($server,$anvandare, $losen);
mysql_select_db($databas);
$query = mysql_query("SELECT * from todo Order by percentage");
while ($r = mysql_fetch_array($query)) {
?>
<?
if ($r[$percentage] <= 25) {
$fontcol=red;
}
if ($r[$percentage] >= 25) {
$fontcol=orange;
}
if ($r[$percentage] >= 50) {
$fontcol=yellow;
}
if ($r[$percentage] >=75) {
$fontcol=green;
}
if ($r[$percentage] >=100) {
$fontcol=green;
} ?>
<center>
<?=$note?></center>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#5D6765" width="95%" id="AutoNumber1">
<tr>
<td width="100%"><br>
<?
$results= mysql_query("SELECT * FROM todo Order by percentage desc");
$id = "id";
$name = "name";
$description = "description";
$left_to_do = "left to do";
$percentage = "percentage";
echo mysql_error();
if (mysql_Numrows($results)>0) //if there are records in the fields
{
$numrows=mysql_NumRows($results); //count them
$x=0;
while ($x<$numrows){ //loop through the records
$theid=mysql_result($results,$x,$id);
$thename=mysql_result($results,$x,$name);
$thedescription=mysql_result($results,$x,$description);
$theltd=mysql_result($results,$x,$left_to_do);
$thepercentage=mysql_result($results,$x,$percentage);
?>
<table width="100%">
<tr>
<th class="subcat" width="60%">
<font size="3"><?=$thename?>:</font>
</th>
<th class="subcat">
<font size="2">Done so far: <font color="<?=$fontcol?>"><?=$thepercentage?>%</font>
</th>
</tr>
<tr>
<td colspan="2" class="row2">
Design Page.<BR>
<?=$theltd?></td>
</tr>
</table>
<BR>
<?
$x++;
}
} else {
?>
<center><b>There is nothing left to do :)!</b></center>
<br>
<?
}
?>
</td>
</tr>
</table>
</center>
</div>
<?}?>