progress bar to work with php mysql values
i have a question in regards to displaying a v开发者_如何转开发isual bar comparing mysql values.
i have the following two scripts :
<?php
require_once("inc/common.inc.php");
session_start();
$SQL = "SELECT * FROM db WHERE id = $user[id] LIMIT 1";
$result = mysql_query($SQL);
while ($db_field = mysql_fetch_assoc($result)) {
print $db_field['actual value'] . "<BR>";
}
?>
and
<?php
require_once("inc/common.inc.php");
session_start();
$SQL = "SELECT * FROM db WHERE id = $user[id] LIMIT 1";
$result = mysql_query($SQL);
while ($db_field = mysql_fetch_assoc($result)) {
print $db_field['max value'] . "<BR>";
}
?>
these two queries show me the actual value and the max value of my user's health.
as of now im printing both values next to each other like 95/100.
i would like to display the above in form of a progress bar according to max and actual.
Any ideas or sugestions would be greatly appreciated. Thank you. the below answer doesnt seem to work.
For e.g.
<?php
$percent = intval($actual_value*100/$max_value);
?>
<div style="width: 200px; background-color: green;">
<span style="width: <?php echo $percent;?>%; background-color: red;"></span>
</div>
$max_value
should be greater than zero of course :)
you could go with a JS progress bar. Assign one value to each progress bar, animate and this should do the trick
精彩评论