⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 voting.php

📁 希望这个对大家有用
💻 PHP
字号:
<?php require_once('Connections/vote.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_rsVoting = "-1";
if (isset($_GET['vid'])) {
  $colname_rsVoting = (get_magic_quotes_gpc()) ? $_GET['vid'] : addslashes($_GET['vid']);
}
mysql_select_db($database_vote, $vote);
$query_rsVoting = sprintf("SELECT * FROM view2 WHERE vote_id = %s", GetSQLValueString($colname_rsVoting, "int"));
$rsVoting = mysql_query($query_rsVoting, $vote) or die(mysql_error());
$row_rsVoting = mysql_fetch_assoc($rsVoting);
$totalRows_rsVoting = mysql_num_rows($rsVoting);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><?php echo $row_rsVoting['vote_title']; ?></title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function checkFormData() {
  n = form1.elements.length;
  x = 0;
  for ( i = 0; i < n; i++ ) {
    if ( form1.elements[i].checked ) x++;
  }
  if ( x ==0 ) {
    alert ( "请选择要投票的选项!" );
	return false;
  }
}
function result( vid ) {
  location.href = "result.php?vid=" + vid;
}
</script>
</head>

<body>
<table width="100%" border="1" frame="below" rules="none">
  <tr>
    <td align="left" valign="bottom" scope="col"><a href="index.php"><img src="images/logo.gif" width="160" height="33" border="0" /></a></td>
    <td align="left" valign="bottom" scope="col"><a href="index.php">系统首页</a></td>
    <td align="right" valign="bottom" scope="col"><a href="admin.php">后台管理&nbsp;</a></td>
    <td align="right" valign="bottom" scope="col"><?php echo date("Y年n月j日"); ?>&nbsp;</td>
  </tr>
</table>
<form action="addcount.php" method="post" name="form1" id="form1" onsubmit="return checkFormData()">
  <table width="300" border="1" align="center" cellpadding="3" rules="none">
    <tr>
      <th colspan="2" nowrap="nowrap" bgcolor="#666666" class="title" scope="col"><?php echo $row_rsVoting['vote_title']; ?></th>
    </tr>
<?php do { ?>
    <tr>
      <td align="right"><input name="items[]" type="<?php echo $row_rsVoting['vote_type']; ?>" id="items[]" value="<?php echo $row_rsVoting['vote_description']; ?>" /></td>
	  <td><?php echo $row_rsVoting['vote_description']; ?></td>
    </tr>
<?php } while ( $row_rsVoting = mysql_fetch_assoc($rsVoting) ); ?>    
    <tr>
      <td height="32" colspan="2" align="center"><input name="hidVoteId" type="hidden" id="hidVoteId" value="<?php echo $_GET["vid"]; ?>" />
        <input name="btnVoting" type="submit" id="btnVoting" value="投票" />
        &nbsp;
        <input name="btnResult" type="button" id="btnResult" onclick="result(<?php echo $_GET["vid"]; ?>);" value="查看结果" /></td>
    </tr>
  </table>
</form>
</body>
</html>
<?php
mysql_free_result($rsVoting);
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -