MySQL/PHP/Dreamweaver Question?

Not sure if this will be a function of PHP, MySQL or Dreamweaver but basically I need to know if I can do conditional formating on my PHP page based on the dynamic data that is diplayed.

I have a basic PHP page that returns dynamic data based on a parameter that is passed from a seperate form. I have built just a basic dynamic table in dreamweaver with a repeating section to display all the returned data. The data is returned like so:

Account Number     Address            Date                  Recall Rate        Exit Rate
12345678            100 Main St        10/2/2004            10.20%             11.57%
23456789            101 Elm St          9/1/2003               8.50%               7.56%
And so on

This data is displayed in a dynamic table with visible borders for each cell etc.

I need to use some type of conditional formating to color code the background and or font color of the Recall Rate and Exit Rate cells based on the value that is returned.

For example I would like to have the background color of the cell be red if the rate is above 12.00%, Yellow if the rate is between 10.00% - 12.00%, Green if the rate is below 10.00%. Ideally I would like to color code the font and the background ( Light green background , Dark green font, Light Yellow background, Dark yellow font etc.) but at this point I would be happy with just one of the other!

Thanks Rob!
LVL 1
ashvillerobAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gruntarCommented:
I don't what you mean "dynamic" table. i guess you're using PHP and mySQL to retrieve data for your table.
take a look at this code..


$sql_data = mysql_query("SELECT recall_rate, exit_rate, * FROM table");

echo '<table>';
echo '<tr>';

echo '<td>Account Number</td>'
echo '<td>Address</td>'
echo '<td>Date</td>'
echo '<td>Recall Rate</td>'
echo '<td>Exit Rate</td>'

echo '</tr>';

while($row_data = mysql_fetch_array($sql_data)){

$rate = (float) $row_data['exit_rate'];

        if($rate < 10.0) {
                $color = 'Yellow';
        } elseif($rate < 12.0) {
                 $color = 'Green';
        } else {
                 $color = 'Red';
        }

echo '<tr>';

echo '<td>' . $row_data['Account_Number'] . '</td>'
echo '<td>' . $row_data['Address'] . '</td>'
echo '<td>' . $row_data['Date'] . '</td>'
echo '<td>' . $row_data['Recall_Rate'] . '</td>'
echo '<td bgcolor="' . $color . '">' . $row_data['Exit_Rate'] . '</td>'

echo '</tr>';
}
echo '</table>';


That would be "draft" for your code. Any questions?

Cheers
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.