とPHPでのデータベース・フィールドに値をチェックしますそれはYで最初のチェックボックスを挿入するだけですが、私が達成したいのは、ユーザーが例えば、科学および数学の場合は、データベースフィールドにScience,Mathematics
として挿入する必要があります。挿入倍数は、Dreamweaverの
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;
}
}
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_insert"])) && ($_POST["MM_insert"] == "main_form")) {
$insertSQL = sprintf("INSERT INTO regis (email, write_exam) VALUES (%s, %s)",
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString(isset($_POST['written_tests']) ? "true" : "", "defined","'Y'","'N'"));
mysql_select_db($database_sample, $sample);
$Result1 = mysql_query($insertSQL, $sample) or die(mysql_error());
}
HTML
<form id="subject_form" action="user.php">
<input name="subject" type="checkbox" id="subject" value="Science" />
Science
<input name="subject" type="checkbox" id="subject" value="Mathematics" />
Mathematics
</form>
あなたは、チェックボックスのHTMLコードを表示してくださいすることができますか? – Mujahidh