|
 |
|
การเก็บค่า แบบสอบถาม ต้องการให้ข้อที่ไม่ได้ลือกคำตอบ เก็บค่าเป็น X |
|
 |
|
|
 |
 |
|
ผมต้องการให้มันเก็บค่าเป็น X ถ้าผู้ตอบแบบสอบถามไม่ได้ตอบข้อไหนไว้
รบกวนโค้ดด้วยนะครับ
Code (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;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tbl_poll (q1, q21, q22, q22_1q, q23, q23_1, q23_1q, q23_2, q23_2q, q23_3, q23_3q, q23_4, q23_4q, q23_5, q23_5q, q24, q24_1q, q24_2q, q3, q3_1, q3_2, q3_3, q3_4, q3_5, q3_5q, q41, q41_q, q42, q42_q, q43, q43_q, q44, q44_q, q45, q45_q, q46, q46_q, q47, q47_q, q48, q48_q, q49, q49_q, q410, q410_q, q5) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['q1'], "text"),
GetSQLValueString($_POST['q21'], "text"),
GetSQLValueString($_POST['q22'], "text"),
GetSQLValueString($_POST['q22_1q'], "text"),
GetSQLValueString($_POST['q23'], "text"),
GetSQLValueString(isset($_POST['q23_1']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['q23_1q'], "text"),
GetSQLValueString(isset($_POST['q23_2']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['q23_2q'], "text"),
GetSQLValueString(isset($_POST['q23_3']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['q23_3q'], "text"),
GetSQLValueString(isset($_POST['q23_4']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['q23_4q'], "text"),
GetSQLValueString(isset($_POST['q23_5']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['q23_5q'], "text"),
GetSQLValueString($_POST['q24'], "text"),
GetSQLValueString($_POST['q24_1q'], "text"),
GetSQLValueString($_POST['q24_2q'], "text"),
GetSQLValueString($_POST['q3'], "text"),
GetSQLValueString(isset($_POST['q3_1']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['q3_2']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['q3_3']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['q3_4']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['q3_5']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['q3_5q'], "text"),
GetSQLValueString($_POST['q41'], "text"),
GetSQLValueString($_POST['q41_q'], "text"),
GetSQLValueString($_POST['q42'], "text"),
GetSQLValueString($_POST['q42_q'], "text"),
GetSQLValueString($_POST['q43'], "text"),
GetSQLValueString($_POST['q43_q'], "text"),
GetSQLValueString($_POST['q44'], "text"),
GetSQLValueString($_POST['q44_q'], "text"),
GetSQLValueString($_POST['q45'], "text"),
GetSQLValueString($_POST['q45_q'], "text"),
GetSQLValueString($_POST['q46'], "text"),
GetSQLValueString($_POST['q46_q'], "text"),
GetSQLValueString($_POST['q47'], "text"),
GetSQLValueString($_POST['q47_q'], "text"),
GetSQLValueString($_POST['q48'], "text"),
GetSQLValueString($_POST['q48_q'], "text"),
GetSQLValueString($_POST['q49'], "text"),
GetSQLValueString($_POST['q49_q'], "text"),
GetSQLValueString($_POST['q410'], "text"),
GetSQLValueString($_POST['q410_q'], "text"),
GetSQLValueString($_POST['q5'], "text"));
mysql_select_db($database_connect, $connect);
$Result1 = mysql_query($insertSQL, $connect) or die(mysql_error());
$insertGoTo = "endpoll.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2010-01-14 10:22:43 |
By :
palmza |
View :
1123 |
Reply :
0 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 00
|