仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1033|回复: 8
打印 上一主题 下一主题

[DIV+CSS] 来讲讲:CSS完成星级评分III

[复制链接]
蒙在股里 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 00:26:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
业界越来越关注DIV+CSS的标准化设计,大到各大门户网站,小到不计其数的个人网站。
起首是完成的道理
从上一个css完成星级评分I、II,但是看出,只需能辨认onclick和将数据纪录至数据库中存储,然后从数据库中挪用出数据举行盘算就
能够失掉以后的评分均值――以后的分值。

1.上面是创建数据库的sql
以下是援用片断:
CREATETABLEratings(
idINTNOTNULLAUTO_INCREMENTPRIMARYKEY,
total_votesINTNOTNULL,
total_valueINTNOTNULL,
which_idINTNOTNULL,
which_tableVARCHAR(255),
used_ipsLONGTEXTNULL
);2.参数文件援用
以下是援用片断:
<?php
require("connectDB.php");
require("closeDB.php");
require("tableName.php");
require("openDB.php");
?>
3.显现投票程序和更新投票数据程序
以下是援用片断:
<?php
$rating_posted=$_GET[vote];//pasedvariablebythethestarsvalue
$id=$_GET[id];
$query=mysql_query("SELECTtotal_votes,total_value,used_ipsFROM$tableNameWHEREid=".$id."")ordie("Error:".mysql_error());
$numbers=mysql_fetch_assoc($query);
$checkIP=unserialize($numbers[used_ips]);
$count=$numbers[total_votes];//howmanyvotestotal
$current_rating=$numbers[total_value];//totalnumberofratingaddedtogetherandstored
$sum=$rating_posted+$current_rating;//addtogetherthecurrentvotevalueandthetotalvotevalue
$tense=($count==1)?"vote":"votes";//pluralformvotes/vote
$voted=@mysql_fetch_assoc(@mysql_query("SELECTtitleFROM$tableNameWHEREused_ipsLIKE%".$_SERVER[REMOTE_ADDR]."%ANDid=$id"));//Patternmatchip:suggestedbyBramus!http://www.bram.us/-thisvariablesearchesthroughthepreviousipaddressthathavevotedandreturnstrueorfalse

if($voted){
echo"<divclass=/"rating/">".
"<ulclass=/"star-rating/">".
"<liclass=/"current-rating/"style=/"width:".@number_format($current_rating/$count,2)*20."px;/">Currentrating.</li>".
"<liclass=/"one-star/">1</li>".
"<liclass=/"two-stars/">2</li>".
"<liclass=/"three-stars/">3</li>".
"<liclass=/"four-stars/">4</li>".
"<liclass=/"five-stars/">5</li>".
"</ul>".
"<p>Rating:<strong>".@number_format($current_rating/$count,2)."</strong>{".$count."".$tense."cast}<br/>Youhavepreviouslyvoted.</p></div>";//showthecurrentvalueofthevotewiththecurrentnumbers
}else{

if(isset($_GET[vote])){

if($sum==0){
$added=0;//checkingtoseeifthefirstvotehasbeentallied
}else{
$added=$count+1;//incrementthecurrentnumberofvotes
}

if(is_array($checkIP)){
array_push($checkIP,$_SERVER[REMOTE_ADDR]);//ifitisanarrayi.e.alreadyhasentriesthepushinanothervalue
}else{
$checkIP=array($_SERVER[REMOTE_ADDR]);//forthefirstentry
}

$insert=serialize($checkIP);
mysql_query("UPDATE$tableNameSETtotal_votes=".$added.",total_value=".$sum.",used_ips=".$insert."WHEREid=".$_GET[id]."");

echo"<divclass=/"rating/"><p>Rating:<strong>".@number_format($sum/$added,2)."</strong>{".$added."".$tense."cast}<span>Thankyouforyourvote!</span></p></div>";//showtheupdatedvalueofthevote
}else{
?>4.会见者评分程序
以下是援用片断:
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS:StarRaterExample</title>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8">
<linkhref="styles2-1.css"rel="stylesheet"type="text/css"media="all">
</head>
<body>
<divclass="rating">
<p>Howclearwasthistutorial?</p>
<ulclass="star-rating">
<liclass="current-rating"style="width:<?phpecho@number_format($current_rating/$count,2)*20?>px;">Currentrating</li>
<li><ahref="<?phpecho$_SERVER[PHP_SELF]."?".$_GET[section]."&id=".$_GET[id]."&vote=1";?>"title="Ratethis1staroutof5"class="one-star">1</a></li>
<li><ahref="<?phpecho$_SERVER[PHP_SELF]."?".$_GET[section]."&id=".$_GET[id]."&vote=1";?>"title="Ratethis2starsoutof5"class="two-stars">2</a></li>
<li><ahref="<?phpecho$_SERVER[PHP_SELF]."?".$_GET[section]."&id=".$_GET[id]."&vote=1";?>"title="Ratethis3starsoutof5"class="three-stars">3</a></li>
<li><ahref="<?phpecho$_SERVER[PHP_SELF]."?".$_GET[section]."&id=".$_GET[id]."&vote=1";?>"title="Ratethis4starsoutof5"class="four-stars">4</a></li>
<li><ahref="<?phpecho$_SERVER[PHP_SELF]."?".$_GET[section]."&id=".$_GET[id]."&vote=1";?>"title="Ratethis5starsoutof5"class="five-stars">5</a></li>
</ul>
</body></html>5.最新评分了局提醒
以下是援用片断:
<?php
echo"<p>Rating:<strong>".@number_format($sum/$count,2)."</strong>{".$count."".$tense."cast}</p></div>";//showthecurrentupdatedvalueofthevote
}//endissetgetvote
}//endvotedtrue,false
?>下一步是将了局记进数据库,如今没偶然间往研讨了,请人人守候下一篇文章大概往远出处浏览!
原文:Creatingastarratingsystempart(3)
链接:http://slim.climaxdesigns.com/tutorial.php?id=3
版权:版权回原作者一切,翻译文档版权回自己|greengnn,转载请说明出处www.jluvip.com/blog
我们用php来完成
先看看效果:http://gnn.80x86.cn/starrating
</p>
目前我们的站就是div+css做的,美工可以通过css直接控制我的程序输出的页面动态数据的样式DIV就只是布局元素.
再现理想 该用户已被删除
沙发
发表于 2015-1-16 23:24:16 | 只看该作者

来讲讲:CSS完成星级评分III

我深感到交流的重要。善于交流的人才是善于学习的人。在整个技术的学习过程中,我总结了四大定律:兴趣、恒心、虚心、时间。
若天明 该用户已被删除
板凳
发表于 2015-1-29 06:37:37 | 只看该作者
不管老师做怎样的解释,而我却对它感到很是吃力,诸如里面有许多不知道的功能。
地板
发表于 2015-2-5 23:27:51 | 只看该作者
Dreamweaver是集网页制作和管理网站于一身的所见即所得网页编辑器,在编辑时能同时看到源码和设计界面,非常方便新手学习制作网页。
山那边是海 该用户已被删除
5#
发表于 2015-2-14 05:16:27 | 只看该作者
不管老师做怎样的解释,而我却对它感到很是吃力,诸如里面有许多不知道的功能。
小妖女 该用户已被删除
6#
发表于 2015-3-4 04:48:08 | 只看该作者
Dreamweaver是集网页制作和管理网站于一身的所见即所得网页编辑器,在编辑时能同时看到源码和设计界面,非常方便新手学习制作网页。
活着的死人 该用户已被删除
7#
发表于 2015-3-11 16:56:46 | 只看该作者
滚动条)层属性--溢出(visible/hidden/scroll/auto)
admin 该用户已被删除
8#
发表于 2015-3-19 02:26:43 | 只看该作者
以上大概就是文字图片的一些链接方法,通过学习Dreamweaver、练习让我对dreameaver8有了进一步的认识,他其实是一款很好的建立Web站点和应用程序的软件。它将可视布局工具、应用程序开发功能和代码编辑支持组合在一起,其功能强大,使得各个层次的开发人员和设计人员都能够快速创建界面吸引人的基于标准的网站和应用程序。
精灵巫婆 该用户已被删除
9#
发表于 2015-3-27 05:10:31 | 只看该作者
还可以在Dreamweaver常用工具中选择超级链接,完成相应的填写即可。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-3 13:33

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表