$hostname_dymenu_conn = "localhost";
$database_dymenu_conn = "cttlee";
$username_dymenu_conn = "cttlee";
$password_dymenu_conn = "cttlee";
$dymenu_conn = mysql_pconnect($hostname_dymenu_conn, $username_dymenu_conn, $password_dymenu_conn) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_query("SET NAMES utf8");
?>
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']) . '&cttlee=male';
}
else {
$editFormAction .= "?cttlee=male";
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1") && isset($_GET['cttlee'])) {
$insertSQL = sprintf("INSERT INTO records (Name, Zip) VALUES (%s, %s)",
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['zip'], "text"));
//mysql_select_db($database_dymenu_conn, $dymenu_conn);
//$Result1 = mysql_query($insertSQL, $dymenu_conn) or die(mysql_error());
$insertGoTo = "dymenu.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_dymenu_conn, $dymenu_conn);
$query_rs_county = "SELECT * FROM county ORDER BY cID ASC";
$rs_county = mysql_query($query_rs_county, $dymenu_conn) or die(mysql_error());
$row_rs_county = mysql_fetch_assoc($rs_county);
$totalRows_rs_county = mysql_num_rows($rs_county);
$colname_rs_town = "-1";
if (isset($_POST['county'])) {
$colname_rs_town = $_POST['county'];
}
mysql_select_db($database_dymenu_conn, $dymenu_conn);
$query_rs_town = sprintf("SELECT * FROM town WHERE tCounty = %s", GetSQLValueString($colname_rs_town, "text"));
$rs_town = mysql_query($query_rs_town, $dymenu_conn) or die(mysql_error());
$row_rs_town = mysql_fetch_assoc($rs_town);
$totalRows_rs_town = mysql_num_rows($rs_town);
$colname_rs_zip = "-1";
if (isset($_POST['town'])) {
$colname_rs_zip = $_POST['town'];
}
mysql_select_db($database_dymenu_conn, $dymenu_conn);
$query_rs_zip = sprintf("SELECT * FROM zip WHERE zTown = %s", GetSQLValueString($colname_rs_zip, "text"));
$rs_zip = mysql_query($query_rs_zip, $dymenu_conn) or die(mysql_error());
$row_rs_zip = mysql_fetch_assoc($rs_zip);
$totalRows_rs_zip = mysql_num_rows($rs_zip);
?>
?⊥?憿峕?隞?/title><br />
<script type="text/javascript"><br />
<!--<br />
function MM_findObj(n, d) { //v4.01<br />
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {<br />
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}<br />
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];<br />
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);<br />
if(!x && d.getElementById) x=d.getElementById(n); return x;<br />
}<br />
function flevSubmitForm() { // v1.1<br />
// Copyright 2002, Marja Ribbers-de Vroed, FlevOOware (www.flevooware.nl/dreamweaver/)<br />
var sF = arguments[0], oF = MM_findObj(sF), sA = (arguments.length > 1) ? arguments[1] : ""; <br />
if (oF) {if (sA != "") {oF.action = sA;} oF.submit(); document.MM_returnValue = false;}<br />
}<br />
//--><br />
</script><br />
</head><br />
<br />
<body><br />
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>"><br />
<table width="350" border="1" align="center" cellpadding="1" cellspacing="1"><br />
<tr><br />
<td width="80">憪枏?</td><br />
<td width="207"><input name="name" type="text" id="name" value="<?php echo $_POST['name']; ?>" /></td><br />
</tr><br />
<tr><br />
<td>?菟??�??/td><br />
<td><select name="county" id="county" onchange="flevSubmitForm('form1','dymenu.php');return document.MM_returnValue"><br />
<?php<br />
do { <br />
?><br />
<option value="<?php echo $row_rs_county['cID']?>"<?php if (!(strcmp($row_rs_county['cID'], $_POST['county']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rs_county['cName']?></option><br />
<?php<br />
} while ($row_rs_county = mysql_fetch_assoc($rs_county));<br />
$rows = mysql_num_rows($rs_county);<br />
if($rows > 0) {<br />
mysql_data_seek($rs_county, 0);<br />
$row_rs_county = mysql_fetch_assoc($rs_county);<br />
}<br />
?><br />
</select><br />
<select name="town" id="town" onchange="flevSubmitForm('form1','dymenu.php');return document.MM_returnValue"><br />
<?php<br />
do { <br />
?><br />
<option value="<?php echo $row_rs_town['tID']?>"<?php if (!(strcmp($row_rs_town['tID'], $_POST['town']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rs_town['tName']?></option><br />
<?php<br />
} while ($row_rs_town = mysql_fetch_assoc($rs_town));<br />
$rows = mysql_num_rows($rs_town);<br />
if($rows > 0) {<br />
mysql_data_seek($rs_town, 0);<br />
$row_rs_town = mysql_fetch_assoc($rs_town);<br />
}<br />
?><br />
</select><br />
<select name="zip" id="zip"><br />
<?php<br />
do { <br />
?><br />
<option value="<?php echo $row_rs_zip['zCode']?>"<?php if (!(strcmp($row_rs_zip['zCode'], $_POST['zip']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rs_zip['zName']?></option><br />
<?php<br />
} while ($row_rs_zip = mysql_fetch_assoc($rs_zip));<br />
$rows = mysql_num_rows($rs_zip);<br />
if($rows > 0) {<br />
mysql_data_seek($rs_zip, 0);<br />
$row_rs_zip = mysql_fetch_assoc($rs_zip);<br />
}<br />
?><br />
</select></td><br />
</tr><br />
<tr><br />
<td colspan="2" align="right"><input type="submit" name="button" id="button" value="?�枂" /></td><br />
</tr><br />
</table><br />
<input type="hidden" name="MM_insert" value="form1" /><br />
</form><br />
</body><br />
</html><br />
<?php<br />
mysql_free_result($rs_county);<br />
<br />
mysql_free_result($rs_town);<br />
<br />
mysql_free_result($rs_zip);<br />
?><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
county這個資料表有:cID,cName<br />
<br />
town資料表有:tID,tCounty,tName<br />
<br />
zip這資料表有:zID,zTown,zName,zCode <br />
<br></div></table></center><br>
<br><hr size=1> 共 2 人回應 選擇頁數 <a href=j2h-380-0.html>【第1 頁】 </a>
<p>
<table width="90%" height=65 border="1" cellpadding=1 cellspacing=0 bordercolorlight=#346783 bordercolordark=#FFFFFF bgcolor="#F0F9FF">
<tr align="center">
<td width="14%" ALIGN="left" VALIGN="TOP" NOWRAP>姓名:</td>
<td align="left" colspan=3><input NAME="j2h" MAXLENGTH="16" SIZE="60" value=''>
</td>
</tr>
<tr align="center">
<td ALIGN="left" VALIGN="TOP" NOWRAP>佈告內容:</td>
<td align="left" colspan=3> <textarea name="j2h5" ROWS="15" COLS="80" ></textarea>
</td>
</tr>
<tr>
<td align=right>其他選項:</td>
<td colspan=3> </td>
</tr>
<tr align="center">
<td ALIGN="RIGHT" VALIGN="TOP" NOWRAP colspan="4"> <p align="center"><br> <input type=submit value='確定發言' onClick="this.disable=true;">
</td></tr></table>
</center></body></html> |