Home > php教程 > php手册 > php调查系统1

php调查系统1

WBOY
Release: 2016-06-13 10:23:36
Original
973 people have browsed it

//程序名 recordvotepoll.php3
//作者:phpstudent
//本程序用于记录投票数
//接口参数 $vpollid调查ID,$vchioceid选项ID,在提交表单中必须有着两个参数,一般$vpollid

require(database.php3); //DATABASE.PHP3是屏蔽了MYSQL及ORACLE差异性的自定义数据库接口

$db = new database();
$db->openDefaultConnection();

$SQL = "SELECT chiocenum from pollchioce where pollid=".$vpollid." and chioceid = ".$vchioceid;
$db->openResultset($SQL);
$db->rstNext();
$vpolldata=$db->getItem(1);
$vpolldata++; //增加票数
//更新数据表
$SQL = "update pollchioce set chiocenum = ".$vpolldata." where
pollid=".$vpollid." and chioceid = ".$vchioceid;
$db->executeUpdate($SQL);
$db->executeUpdate("COMMIT");

$db->closeConnection();
echo("
感谢您参与本次调查
以下是调查结果
");
include(showresult.php3); //showresult.php3是显示结果的文件

?>

数据表的结构如下:
1、
CREATE TABLE poll (
pollid tinyint(1) DEFAULT 0 NOT NULL,


polltitle varchar(40) NOT NULL,
polldetail varchar(200) NOT NULL,
PRIMARY KEY (pollid),
UNIQUE pollid (pollid)
);
2、
CREATE TABLE pollchioce (
pollid tinyint(1) DEFAULT 0 NOT NULL,
chioceid tinyint(1) DEFAULT 0 NOT NULL,
chiocename varchar(20) NOT NULL,
chiocenum int(5) DEFAULT 0 NOT NULL,
chiocecolor varchar(6) NOT NULL
);
Related labels:
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