Php 生成高达100%的上/下评级总和
我写了一个评分系统(上/下)。用户将投票保存在数据库中:Php 生成高达100%的上/下评级总和,php,Php,我写了一个评分系统(上/下)。用户将投票保存在数据库中: articles ( id int not null auto_increment, article_title varchar (100) not null, ... vote_up int not null default '0', vote_down int not null default '0', vote_sum int not null default '0' .. ) 我想显示一
articles (
id int not null auto_increment,
article_title varchar (100) not null,
...
vote_up int not null default '0',
vote_down int not null default '0',
vote_sum int not null default '0'
..
)
我想显示一个显示上升/下降评级状态的栏,如下所示:
如何计算升/降分数的百分比?你有什么想法吗?你可以通过创建两个跨度(或div)来实现这一点,并相应地更改它们的百分比宽度 例如,如果投票赞成=20,投票反对=30,则
total_votes = vote_up + vote_down;
vote_up_pctg = vote_up/total_votes *100;
vote_down_pctg = vote_down/total_votes *100;
因此,第一个跨距或div宽度将为40%,第二个跨距或div宽度将为60%
您必须使用CSS和PHP(或任何服务器端语言)完成以上所有工作。你也可以在js中这样做,但加载后需要一些时间。你有没有尝试过?我猜做一个简单的
vote\u up/vote\u sum
不是这里的问题。然后呢?尽量说得具体一点。你想这样做吗: