+ -
当前位置:首页 → 问答吧 → 简单的统计工具PHP+CSS

简单的统计工具PHP+CSS

时间:2009-09-24

来源:互联网

<?php
session_start();

$options = array(\"a\"=>\"赞同\",
\"b\"=>\"反对\",
\"c\"=>\"放弃\",
);

$radio = $_POST['radio'];

$_SESSION[\"counter_\".$radio]++;

foreach($options as $item=>$value){
$counter_total += $_SESSION[\"counter_\".$item];
}

foreach($options as $item=>$value){
$_SESSION[\"counter_percent_\".$item]=sprintf(\"%.2f\",$_SESSION[\"counter_\".$item]/$counter_total)*100;
}

?>
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
<title>无标题文档</title>
<style type=\"text/css\">
<!--
.graph {
position: relative; /* IE is dumb */
width: 200px;
border: 1px solid #B1D632;
padding: 2px;
margin-bottom:3px;
}
.graph .bar {
display: block;
position: relative;
background: #B1D632;
text-align: center;
color: #333;
height: 2em;
line-height: 2em;
}
.graph .bar span {
position: absolute;
left: 1em;
}
</style>
</head>
<body>
<?php
foreach($options as $item=>$value){
?>
<div class=\"graph\"> <strong class=\"bar\" style=\"width: <?php echo $_SESSION[\"counter_percent_\".$item];?>%;\"><?php echo $_SESSION[\"counter_percent_\".$item];?>%</strong> </div>
<?php
}
?>
<div>
<form name=\"form1\" action=\"statistics.php\" method=\"post\" >
<?php
foreach($options as $item=>$value){
?>
<label>
<input type=\"radio\" name=\"radio\" value=\"<?php echo $item?>\" />
<?php echo $value?> </label>
<?php
}
?>
<input type=\"submit\" />
</form>
</div>
</body>
</html>

作者: bianxin   发布时间: 2009-09-24

学习了。。。。。。。。

作者: 林哥   发布时间: 2009-09-24

很不错

作者: 网中浪子   发布时间: 2009-09-24

热门下载

更多