0
我有一個內置在Adobe Dreamweaver中的表單。它可以工作,但是當複選框被選中時,最後一個複選框的值將提交給數據庫。在Dreamweaver中使用多個複選框
Dreamweaver中是否有任何選項可使表單使用所有複選框?
<?php require_once('Connections/MySQL_CSFTDB.php'); ?>
<?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_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO articles (articletitle, articledescription) VALUES (%s, %s)",
GetSQLValueString($_POST['articletitle'], "text"),
GetSQLValueString($_POST['articledescription'], "text"));
mysql_select_db($database_MySQL_CSFTDB, $MySQL_CSFTDB);
$Result1 = mysql_query($insertSQL, $MySQL_CSFTDB) or die(mysql_error());
}
?>
<!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=UTF-8" />
<title>Untitled Document</title>
<link href="twoColLiqLtHdr.css" rel="stylesheet" type="text/css" /><!--[if lte IE 7]>
<style>
.content { margin-right: -1px; } /* this 1px negative margin can be placed on any of the columns in this layout with the same corrective effect. */
ul.nav a { zoom: 1; } /* the zoom property gives IE the hasLayout trigger it needs to correct extra whiltespace between the links */
</style>
<![endif]-->
</head>
<body>
<div class="container">
<div class="header"><!-- end .header --></div>
<div class="sidebar1">
<ul class="nav">
<li><a href="index.php">Home</a></li>
<li><a href="#">Search</a></li>
<li><a href="addnew.php">Add New Article</a></li>
<li><a href="addnew.php">Article Admin.</a></li>
<li><a href="#">Tag Admin.</a></li>
</ul>
<p><!-- end .sidebar1 --></p>
</div>
<div class="content">
<h1>Article Database</h1>
<p>- Add a new article.</p>
<form action="<?php echo $editFormAction; ?>" id="form1" name="form1" method="POST">
<table width="100%" border="0" cellpadding="6">
<tr>
<td width="29%" align="right"><label for="articletitle">Article Title:</label> </td>
<td width="71%" align="left"><input name="articletitle" type="text" id="articletitle" size="50" /></td>
</tr>
<tr>
<td align="right"><label for="articleorganization">Article or Organization:</label></td>
<td align="left"><input name="articleorganization" type="text" id="articleorganization" size="50" /></td>
</tr>
<tr>
<td align="right"><label for="articledate">Access Date:</label></td>
<td align="left"><input name="articledate" type="text" id="articledate" size="50" /></td>
</tr>
<tr>
<td align="right"><label for="articledescription">Article Description:</label></td>
<td align="left"><input name="articledescription" type="text" id="articledescription" size="50" /></td>
</tr>
<tr>
<td colspan="2" align="center" valign="bottom"><p>Article Tags</p></td>
</tr>
<tr>
<td align="right"> </td>
<br />
<label>
<input type="checkbox" name="CheckboxGroup1" value="option 1" id="CheckboxGroup1_0" />
Checkbox 1</label>
<br />
<label>
<input type="checkbox" name="CheckboxGroup1" value="option 2" id="CheckboxGroup1_1" />
Checkbox 2</label>
<td align="left"><p>
<br />
<br />
</p></td>
</tr>
<tr>
<td align="right"> </td>
<td align="left"><p><br />
</p></td>
</tr>
<tr>
<td align="right"> </td>
<td align="left"> </td>
</tr>
<tr>
<td colspan="2" align="center" valign="middle"><input type="submit" name="submit" id="submit" value="Submit" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<!-- end .content --></div>
<div class="footer">
</div>
<!-- end .container --></div>
</body>
</html>
我添加了HTML和PHP的代碼,以便您可以看到我所得到的結果。 – Zrb0529