<?php if(pj1=="great"){
pj_result.Fields.Item("1_A").Value++;}
else if(pj1=="agree"){
pj_result.Fields.Item("1_B").Value++;}
else(pj1=="oppose"){
pj_result.Fields.Item("1_C").Value++;}
?>pj1是三个单选按钮的名称,三者的值为great agree oppose,现在我想如果选great,那么表pj_result下的字段1_A就自动加1;同理选agree,则1_B自动加1;选oppose,则1_C自动加1。
请问应该怎么改?
pj_result.Fields.Item("1_A").Value++;}
else if(pj1=="agree"){
pj_result.Fields.Item("1_B").Value++;}
else(pj1=="oppose"){
pj_result.Fields.Item("1_C").Value++;}
?>pj1是三个单选按钮的名称,三者的值为great agree oppose,现在我想如果选great,那么表pj_result下的字段1_A就自动加1;同理选agree,则1_B自动加1;选oppose,则1_C自动加1。
请问应该怎么改?
怎么看着像 js
<?php require_once('../Connections/connmember.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "../index.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "admin";
$MM_donotCheckaccess = "true";// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}$MM_restrictGoTo = "../index.php?errMsg=3";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?><?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE vote_record SET `1_A`=%s, `1_B`=%s, `1_C`=%s, `2_A`=%s, `2_B`=%s, `2_C`=%s, `3_A`=%s, `3_B`=%s, `3_C`=%s, `4_A`=%s, `4_B`=%s, `4_C`=%s, `5_A`=%s, `5_B`=%s, `5_C`=%s WHERE u_id=%s",
GetSQLValueString($_POST['pj1'], "int"),
GetSQLValueString($_POST['pj1'], "int"),
GetSQLValueString($_POST['pj1'], "int"),
GetSQLValueString($_POST['pj2'], "int"),
GetSQLValueString($_POST['pj2'], "int"),
GetSQLValueString($_POST['pj2'], "int"),
GetSQLValueString($_POST['pj3'], "int"),
GetSQLValueString($_POST['pj3'], "int"),
GetSQLValueString($_POST['pj3'], "int"),
GetSQLValueString($_POST['pj4'], "int"),
GetSQLValueString($_POST['pj4'], "int"),
GetSQLValueString($_POST['pj4'], "int"),
GetSQLValueString($_POST['pj5'], "int"),
GetSQLValueString($_POST['pj5'], "int"),
GetSQLValueString($_POST['pj5'], "int"),
GetSQLValueString($_POST['user_id'], "int")); mysql_select_db($database_conmember, $conmember);
$Result1 = mysql_query($updateSQL, $conmember) or die(mysql_error()); $updateGoTo = "pjls_ok.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}$currentPage = $_SERVER["PHP_SELF"];if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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_RecUser = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_RecUser = $_SESSION['MM_Username'];
}
mysql_select_db($database_conmember, $conmember);
$query_RecUser = sprintf("SELECT m_id, m_name, m_nick, m_birthday, m_level FROM memberdata WHERE m_username = %s", GetSQLValueString($colname_RecUser, "text"));
$RecUser = mysql_query($query_RecUser, $conmember) or die(mysql_error());
$row_RecUser = mysql_fetch_assoc($RecUser);
$totalRows_RecUser = mysql_num_rows($RecUser);$maxRows_RecMember = 10;
$pageNum_RecMember = 0;
if (isset($_GET['pageNum_RecMember'])) {
$pageNum_RecMember = $_GET['pageNum_RecMember'];
}
$startRow_RecMember = $pageNum_RecMember * $maxRows_RecMember;$colname_RecMember = "-1";
if (isset($_GET['m_id'])) {
$colname_RecMember = $_GET['m_id'];
}
mysql_select_db($database_conmember, $conmember);
$query_RecMember = sprintf("SELECT * FROM memberdata WHERE m_id = %s ORDER BY m_joinDate DESC", GetSQLValueString($colname_RecMember, "int"));
$query_limit_RecMember = sprintf("%s LIMIT %d, %d", $query_RecMember, $startRow_RecMember, $maxRows_RecMember);
$RecMember = mysql_query($query_limit_RecMember, $conmember) or die(mysql_error());
$row_RecMember = mysql_fetch_assoc($RecMember);if (isset($_GET['totalRows_RecMember'])) {
$totalRows_RecMember = $_GET['totalRows_RecMember'];
} else {
$all_RecMember = mysql_query($query_RecMember);
$totalRows_RecMember = mysql_num_rows($all_RecMember);
}
$totalPages_RecMember = ceil($totalRows_RecMember/$maxRows_RecMember)-1;$maxRows_timu_pj = 5;
$pageNum_timu_pj = 0;
if (isset($_GET['pageNum_timu_pj'])) {
$pageNum_timu_pj = $_GET['pageNum_timu_pj'];
}
$startRow_timu_pj = $pageNum_timu_pj * $maxRows_timu_pj;mysql_select_db($database_conmember, $conmember);
$query_timu_pj = "SELECT * FROM vote_item WHERE Voteitem_sort = 'teacher'";
$query_limit_timu_pj = sprintf("%s LIMIT %d, %d", $query_timu_pj, $startRow_timu_pj, $maxRows_timu_pj);
$timu_pj = mysql_query($query_limit_timu_pj, $conmember) or die(mysql_error());
$row_timu_pj = mysql_fetch_assoc($timu_pj);$colname_pj_result = "-1";
if (isset($_GET['u_id'])) {
$colname_pj_result = $_GET['u_id'];
}
mysql_select_db($database_conmember, $conmember);
$query_pj_result = sprintf("SELECT * FROM vote_record WHERE u_id = %s", GetSQLValueString($colname_pj_result, "int"));
$pj_result = mysql_query($query_pj_result, $conmember) or die(mysql_error());
$row_pj_result = mysql_fetch_assoc($pj_result);
$totalRows_pj_result = mysql_num_rows($pj_result);
?>
表pj_result的结构:
已经贴出该页面的PHP语法及数据表结构。麻烦帮我看看,谢谢了!
小弟新手,不过觉得你这个问题不难啊。
其思路是:
1.判断 great, agree,oppose三种状态;
2. 相应值加1;
3. 从数据库读出相应字段的值,并赋值到某变量上;
4. 把该变量自动加1;
5. 把该变量的值再写入相应字段中,update一下即可。难道不是么?求指导。
这么写不行吧。
你确定你的结果集可以这么操作?
然后还能更新到数据库里面?