1 / 15
文档名称:

PHP应用实例集锦-投票系统.doc

格式:doc   大小:94KB   页数:15页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

PHP应用实例集锦-投票系统.doc

上传人:1136365664 2018/3/26 文件大小:94 KB

下载得到文件列表

PHP应用实例集锦-投票系统.doc

相关文档

文档介绍

文档介绍:程序8-1
文件名:
<?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 = "";
$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
文件名:
//统计某一投票主题总的投票数和每一投票选项的最大投票数
<?
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 ($