Im new in this programming world. Here is my problem: I need to display result of which I need to show location and gred using colors. For example for total staff the color will be blue and green color for available post. Below is my coding but it will only display a list of location and position for each location. How do I do it in php? How do I calculate number of staff and put the result in table which will show in blue color?

Below is my code:

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



//connect database
$con = mysql_connect("localhost","root");

    die('Could not connect: ' . mysql_error());


//select database to be use
mysql_select_db("mpchr", $con);

// query the database table
$sql = "SELECT Floor_Location, GRED_ID FROM STAFF ";

//run the query againts the mysql function

echo "<table border='1'>

//ceate while loop and loop through result set
while ($row = mysql_fetch_array ($result))
    $Floor_Location= $row ['Floor_Location'];
    $Gred_ID = $row [ 'GRED_ID'];   

    //display the result of the array
    echo "<tr>";
    echo "<td> " . $row['Floor_Location'] . "</td>";
    echo "<td>"  . $row['GRED_ID'] . "</td>";
    echo "</tr>";


echo "</table>";



Appreciate with any help frm you guys.

Edited by Reverend Jim: Fixed formatting

8 Years
Discussion Span
Last Post by rajarajan2017


copy and paste and test the file to get the result, and implement in your code.


// set quantity 
$quantity = 1000; 

// set original and current unit price 
$origPrice = 100; 
$currPrice = 25; 

// calculate difference in price 
$diffPrice = $currPrice - $origPrice; 

// calculate percentage change in price 
$diffPricePercent = (($currPrice - $origPrice) * 100) / $origPrice;


<table border="1" cellpadding="5" cellspacing="0"> 
<td>Cost price</td> 
<td>Current price</td> 
<td>Absolute change in price</td> 
<td>Percent change in price</td> 
<td><font color="red"><b><?php echo $quantity ?></b></font></td> 
<td><font color="green"><b><?php echo $origPrice ?></b></td> 
<td><font color="blue"><?php echo $currPrice ?></b></td> 
<td><font color="grey"><?php echo $diffPrice ?></b></td> 
<td><font color="yellow"><?php echo $diffPricePercent ?>%</b></td> 

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.