Home > php教程 > php手册 > 投票最后显示进度条的百分比怎么算

投票最后显示进度条的百分比怎么算

WBOY
Release: 2016-06-13 09:52:31
Original
1260 people have browsed it




投票最后显示进度条的百分比怎么算

最后显示投票结果,那个进度条的百分比是怎么求出来的
是个数/总数*100 ?

我怎么算不对啊
请前辈们帮帮忙

我来回答




D8888D回贴内容-------------------------------------------------------
是这样算的!可能你哪里出错了吧~把代码贴来看看!!

D8888D回贴内容-------------------------------------------------------
$results = ($row['clicks']/$result)*100;

就这个 ~

D8888D回贴内容-------------------------------------------------------
按人头算
选A的人数/总人数

D8888D回贴内容-------------------------------------------------------
按人头算不是一个道理吗

[img]http://www.111cn.cn/bbs/images/smilies/default/sweat.gif[/img]

D8888D回贴内容-------------------------------------------------------
好像是我求总和的时候求错了

连接类的方法是:
function selectdb($s_field,$s_table,$s_condition = '')
{
if('' != $s_condition)
{
$s_condition = trim($s_condition);
$s_condition = ('o' == strtolower($s_condition[0]) ? ' ' : ' where ').$s_condition;
}
$sql = "select ".$s_field." from ".$s_table.$s_condition;
$res = mysql_query($sql);
if($result['error'] = mysql_error() != "")
{
die($sql.'

'.mysql_error());
}
return $res;
}

总和是这个样子求出来的:
$result= $con -> selectdb('sum(clicks)','reselect','');

好像这个$result不是总和?

D8888D回贴内容-------------------------------------------------------
单选没问题,多选的你就错了。。

D8888D回贴内容-------------------------------------------------------
我是单选的啊。。radio的嘛
我晓得哪错了 ~ [img]http://www.111cn.cn/bbs/images/smilies/default/sweat.gif[/img]
我求和没求对,打印$result始终是5,哈哈

不过我就是不晓得杂个返回求和的sql语句

D8888D回贴内容-------------------------------------------------------
急啊 !!
$con -> selectdb('sum(clicks)','reselect','');
这条语句是没错啊,
为什么
$result = $con -> selectdb('sum(clicks)','reselect','');
$result不是列的总和呢?

D8888D回贴内容-------------------------------------------------------
已解决~
用mysql_result函数,该函数取得query查询结果


[img]http://www.111cn.cn/bbs/images/smilies/default/biggrin.gif[/img]


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template