- 1、本文档共15页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
PHP应用实例集锦-投票系统
程序8-1
文件名:config.inc.php
?php
//定义绘制柱图的基本参数
$total_width = 400; //绘图区的宽
$total_bar_width =200; //柱图的长度
$bar_width = 10 ; //显示投票结果的柱图宽度
$bar_distance = 6 ; //显示投票结果的柱图之间的间距
$top = 10; //柱图离顶边的距离
$x1=1; //柱图的X轴的坐标
$dis_x =40; //柱图与百分比之间的距离
/*配置图像的颜色,依次为:绿色#海蓝#蓝色#浅绿色#银灰色#橙色#淡红#枯黄。
其中,#为分割符*/
$color_str = 0,170,170#150,150,255#157,190,220#0,255,0
#192,192,192#228,196,154#255,180,180#200,200,0;
//设置程序在服务器中存放路径
$index_file = index.php;
$server_url= ereg_replace($index_file,,getenv(HTTP_REFERER));
$user_ip = getenv(REMOTE_ADDR);//获取用户IP地址
$top_char_everyline = 20; //投票主题每行的字符
$char_everyline = 12; //投票选项每行的字符
$hostname=localhost; //MySQL所在主机名称
$username=; //用户名
$password=; //口令
$dbname=db_poll;
$table=table_poll;
$connect = MYSQL_CONNECT($hostname,$username,$password)
OR DIE(连接数据库失败);
MYSQL_select_db($dbname) OR DIE(连接数据库失败);
//用于检验用户名是否存在
function isname_exist($input_name)
{
//定义全局量
global $dbname,$table,$action;
//从数据库表中读取信息
$query = select user_name from $table where user_name =$input_name;
$total = mysql_numrows(mysql_query($query));
if ($total 0)
{
$action = 用户名已存在;
exit;
}
else
{
$action = 用户名不存在;
exit;
}
}
?
程序8-2
文件名:inc_poll_result.php
//统计某一投票主题总的投票数和每一投票选项的最大投票数
?
if (!$poll_subject){
$query = select * from $table where user_name =$user_name;
$result = mysql_query($query) or die(连接数据库错误);
$array_row = mysql_fetch_array($result);
$poll_subject = $array_row[poll_subject];
$poll_result = $array_row[poll_result];
$poll_radio = $array_row[poll_radio];
}
$array_poll_radio = explode(#,$poll_radio);
$array_item =explode(#,$poll_result);
$item_number = sizeof($array_item); //投票选项数
//空白区的高度
$total_height = $top+($bar_width +$bar_distance) * $item_number + $bar_distance;
$total_item = 0;
$temp = 0;
//定义弹出窗口的大小
$td_height = 28;
$open_window_height = ($total_height+40)+($item_number+8)*$td_height;
$open_window_width = $total_width+50;//弹出窗口的宽
for ($i = 0;$i $item_number ;$i+
文档评论(0)