<?php
include_once("connect.php");
try
{
if(!isset($_REQUEST['cid']))
{
echo"没有选取要的选项<a href=index.php>返回</a>";
exit;
}
$sql = "update content set num=num+1 where cid=".$_REQUEST['cid'];
$connect->beginTransaction();
$connect->exec($sql);
$connect->commit();
header("location:index.php");
}catch(Exception $e)
{
$connect->rollBack();
echo"没有选取要的选项<a href=index.php>返回</a>";
}
$connect=null;
?>
本文介绍了一个简单的PHP脚本,用于实现一个投票系统中投票项计数的更新功能。该脚本首先检查用户是否已选择投票选项,然后通过数据库连接进行事务处理,确保投票计数正确更新。
588

被折叠的 条评论
为什么被折叠?



