php调查系统1
程序员文章站
2022-06-16 18:58:24
...
//程序名 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
);
//作者: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
);
下一篇: tomcat 中运作php