0
我試圖製作一個腳本,顯示爲從數據庫中的條形圖統計信息。要做到這一點,我認爲用不同的顏色在另一個欄上劃一個欄,所以結果是一個2色的欄,它可以同時顯示兩個值,在我的案例中,總共嘗試了一些錯誤。繪製條形圖的HTML問題
然後,我想連續顯示這2個彩條中的幾個。但是問題出在我寫的腳本上,所有的酒吧都是一個接一個地出現,而不是並排。誰能告訴我我做錯了什麼?
$Errors=explode("-",$row['fails']);
$Total=explode("-",$row['num_col']);
foreach($Errors as $key => $values)
{
$max = $Total[$key];
$mistakes = $values;
$scale = 10;
$Green=$max*$scale;
$Red=$mistakes*$scale;
//echo "Result ".($max-$mistakes)."/".$max."<br>";
?>
<html>
<style>
.bar1{
width:40px;
background-color:red;
position:absolute;
}
.bar2{
width:40px;
background-color:green;
position:fixed;
}
.gap{
width:100px;
float:left;
}
.space{
width:20px;
float:left;
}
.container {
width : 40px;
height: 100px;
position: relative
}
</style>
<body>
<?php
echo'
<div class="container"><div style="height:'.$Green.'px;" class="bar2"></div>
<div style="height:'.$Red.'px;" class="bar1"></div>
<div style="height:200 px;" class="space"></div></div>
';
}
?>
</body>
</html>
只需添加,我前幾天問了一個類似的問題:HTML vertical bar of two different colors而@Tiago給我說說如何繪製兩條槓起來了答案。
感謝,再次真正有用 –