|
|
|
สอบถามเรื่อง insert ลงฐานข้อมูลแล้วมันบันทึกลงที่ละ 7 ตาราง ของคุงครับ |
|
|
|
|
|
|
|
ถามอะไรล่ะครับ ประเด็นไหน อะไรคือคำถาม
|
|
|
|
|
Date :
2013-05-17 08:20:44 |
By :
cookiephp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คือเวลาผมบันทึกข้อมูลแต่ละครั้งมันจะบันทึกลงที่ละ 7 ข้อมูล ปรกติมันต้องมันทึกลงที่ละ 1 ข้อมูล งง ไหมครับเดียวผมเอาหน้าตารางให้ดู
|
|
|
|
|
Date :
2013-05-17 08:51:59 |
By :
dRufFy |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2013-05-17 09:05:14 |
By :
dRufFy |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอา Code มาแปะ
|
|
|
|
|
Date :
2013-05-17 09:26:02 |
By :
Krungsri |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<?php require_once('Connections/data1.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 re_data (`position`, name, address, Education, major, Exp, sarary) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['education'], "text"),
GetSQLValueString($_POST['major'], "text"),
GetSQLValueString($_POST['exp'], "text"),
GetSQLValueString($_POST['sarary'], "text"));
mysql_select_db($database_data1, $data1);
$Result1 = mysql_query($insertSQL, $data1) or die(mysql_error());
$insertGoTo = "show.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO re_data (`position`, name, address, major, sarary) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['education'], "text"),
GetSQLValueString($_POST['major'], "text"));
mysql_select_db($database_data1, $data1);
$Result1 = mysql_query($insertSQL, $data1) or die(mysql_error());
$insertGoTo = "show.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO re_data (`position`, name, address, Education, major, Exp, sarary) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['education'], "text"),
GetSQLValueString($_POST['major'], "text"),
GetSQLValueString($_POST['exp'], "text"),
GetSQLValueString($_POST['sarary'], "text"));
mysql_select_db($database_data1, $data1);
$Result1 = mysql_query($insertSQL, $data1) or die(mysql_error());
$insertGoTo = "show.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO re_data (`position`, name, address, Education, major, Exp, sarary) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['education'], "text"),
GetSQLValueString($_POST['major'], "text"),
GetSQLValueString($_POST['exp'], "text"),
GetSQLValueString($_POST['sarary'], "text"));
mysql_select_db($database_data1, $data1);
$Result1 = mysql_query($insertSQL, $data1) or die(mysql_error());
$insertGoTo = "show.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO re_data (`position`, name, address, Education, major, Exp, sarary) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['education'], "text"),
GetSQLValueString($_POST['major'], "text"),
GetSQLValueString($_POST['exp'], "text"),
GetSQLValueString($_POST['sarary'], "text"));
mysql_select_db($database_data1, $data1);
$Result1 = mysql_query($insertSQL, $data1) or die(mysql_error());
$insertGoTo = "show.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO re_data (`position`, name, address, Education, major, Exp, sarary) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['education'], "text"),
GetSQLValueString($_POST['major'], "text"),
GetSQLValueString($_POST['exp'], "text"),
GetSQLValueString($_POST['sarary'], "text"));
mysql_select_db($database_data1, $data1);
$Result1 = mysql_query($insertSQL, $data1) or die(mysql_error());
$insertGoTo = "show.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO re_data (`position`, name, address, Education, major, Exp, sarary) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['education'], "text"),
GetSQLValueString($_POST['major'], "text"),
GetSQLValueString($_POST['exp'], "text"),
GetSQLValueString($_POST['sarary'], "text"));
mysql_select_db($database_data1, $data1);
$Result1 = mysql_query($insertSQL, $data1) or die(mysql_error());
$insertGoTo = "show.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_data1, $data1);
$query_Recordset1 = "SELECT name FROM re_data";
$Recordset1 = mysql_query($query_Recordset1, $data1) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!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=windows-874" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="602" border="1">
<tr>
<td colspan="2"><div align="center">
<p> </p>
<p><strong>สมัครงาน</strong></p>
<p> </p>
</div></td>
</tr>
<tr>
<td width="140"><strong>ตำแหน่ง</strong></td>
<td width="446"><strong>
<select name="position" id="position">
<option>เลือก</option>
<option>โปรแกรมเมอร์</option>
<option>นักวิชาการเกษตร</option>
<option>วิศวการยาง</option>
<option>จป วิชาชีพ</option>
</select>
</strong></td>
</tr>
<tr>
<td>ชื่อ-นามสกุล</td>
<td><label for="name2"></label>
<input name="name" type="text" /></td>
</tr>
<tr>
<td>ที่อยู่</td>
<td><label for="address2"></label>
<textarea name="address" id="address2" cols="45" rows="5"></textarea></td>
</tr>
<tr>
<td>ระดับการศึกษา</td>
<td><label for="education2"></label>
<select name="education" id="education2">
<option>ม.6</option>
<option>ปวช.</option>
<option>ปวส.</option>
<option>ปริญญาตรี</option>
<option>ปริญญาโท</option>
</select>
สาขา
<label for="major2"></label>
<input type="text" name="major" /></td>
</tr>
<tr>
<td>ประสบการณ์ทำงาน</td>
<td><label for="exp2"></label>
<textarea name="exp" id="exp2" cols="45" rows="5"></textarea></td>
</tr>
<tr>
<td>เงินเดือน</td>
<td><label for="sarary"></label>
<input type="text" name="sarary" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="save" id="save" value="บันทึก" />
<input type="reset" name="reset" id="reset" value="รีเฟรส" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
</body>
</html>
<?php
|
|
|
|
|
Date :
2013-05-17 09:48:40 |
By :
dRufFy |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เยอะไปหน่อยนะครับ
|
|
|
|
|
Date :
2013-05-17 09:50:51 |
By :
dRufFy |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขออนุญาติแปะให้อ่านง่ายน่ะ
Code (PHP)
<?php require_once('Connections/data1.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 re_data (`position`, name, address, Education, major, Exp, sarary) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['education'], "text"),
GetSQLValueString($_POST['major'], "text"),
GetSQLValueString($_POST['exp'], "text"),
GetSQLValueString($_POST['sarary'], "text"));
mysql_select_db($database_data1, $data1);
$Result1 = mysql_query($insertSQL, $data1) or die(mysql_error());
$insertGoTo = "show.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO re_data (`position`, name, address, major, sarary) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['education'], "text"),
GetSQLValueString($_POST['major'], "text"));
mysql_select_db($database_data1, $data1);
$Result1 = mysql_query($insertSQL, $data1) or die(mysql_error());
$insertGoTo = "show.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO re_data (`position`, name, address, Education, major, Exp, sarary) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['education'], "text"),
GetSQLValueString($_POST['major'], "text"),
GetSQLValueString($_POST['exp'], "text"),
GetSQLValueString($_POST['sarary'], "text"));
mysql_select_db($database_data1, $data1);
$Result1 = mysql_query($insertSQL, $data1) or die(mysql_error());
$insertGoTo = "show.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO re_data (`position`, name, address, Education, major, Exp, sarary) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['education'], "text"),
GetSQLValueString($_POST['major'], "text"),
GetSQLValueString($_POST['exp'], "text"),
GetSQLValueString($_POST['sarary'], "text"));
mysql_select_db($database_data1, $data1);
$Result1 = mysql_query($insertSQL, $data1) or die(mysql_error());
$insertGoTo = "show.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO re_data (`position`, name, address, Education, major, Exp, sarary) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['education'], "text"),
GetSQLValueString($_POST['major'], "text"),
GetSQLValueString($_POST['exp'], "text"),
GetSQLValueString($_POST['sarary'], "text"));
mysql_select_db($database_data1, $data1);
$Result1 = mysql_query($insertSQL, $data1) or die(mysql_error());
$insertGoTo = "show.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO re_data (`position`, name, address, Education, major, Exp, sarary) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['education'], "text"),
GetSQLValueString($_POST['major'], "text"),
GetSQLValueString($_POST['exp'], "text"),
GetSQLValueString($_POST['sarary'], "text"));
mysql_select_db($database_data1, $data1);
$Result1 = mysql_query($insertSQL, $data1) or die(mysql_error());
$insertGoTo = "show.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO re_data (`position`, name, address, Education, major, Exp, sarary) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['education'], "text"),
GetSQLValueString($_POST['major'], "text"),
GetSQLValueString($_POST['exp'], "text"),
GetSQLValueString($_POST['sarary'], "text"));
mysql_select_db($database_data1, $data1);
$Result1 = mysql_query($insertSQL, $data1) or die(mysql_error());
$insertGoTo = "show.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_data1, $data1);
$query_Recordset1 = "SELECT name FROM re_data";
$Recordset1 = mysql_query($query_Recordset1, $data1) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!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=windows-874" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="602" border="1">
<tr>
<td colspan="2"><div align="center">
<p> </p>
<p><strong>สมัครงาน</strong></p>
<p> </p>
</div></td>
</tr>
<tr>
<td width="140"><strong>ตำแหน่ง</strong></td>
<td width="446"><strong>
<select name="position" id="position">
<option>เลือก</option>
<option>โปรแกรมเมอร์</option>
<option>นักวิชาการเกษตร</option>
<option>วิศวการยาง</option>
<option>จป วิชาชีพ</option>
</select>
</strong></td>
</tr>
<tr>
<td>ชื่อ-นามสกุล</td>
<td><label for="name2"></label>
<input name="name" type="text" /></td>
</tr>
<tr>
<td>ที่อยู่</td>
<td><label for="address2"></label>
<textarea name="address" id="address2" cols="45" rows="5"></textarea></td>
</tr>
<tr>
<td>ระดับการศึกษา</td>
<td><label for="education2"></label>
<select name="education" id="education2">
<option>ม.6</option>
<option>ปวช.</option>
<option>ปวส.</option>
<option>ปริญญาตรี</option>
<option>ปริญญาโท</option>
</select>
สาขา
<label for="major2"></label>
<input type="text" name="major" /></td>
</tr>
<tr>
<td>ประสบการณ์ทำงาน</td>
<td><label for="exp2"></label>
<textarea name="exp" id="exp2" cols="45" rows="5"></textarea></td>
</tr>
<tr>
<td>เงินเดือน</td>
<td><label for="sarary"></label>
<input type="text" name="sarary" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="save" id="save" value="บันทึก" />
<input type="reset" name="reset" id="reset" value="รีเฟรส" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
</body>
</html>
<?php
|
|
|
|
|
Date :
2013-05-17 10:07:45 |
By :
dekkuza |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พ่อคุณเอ้ย โค๊ด insert ซ้ำกัน 7 ตัว T_T ลบให้เหลือ ตัวเดียวพอ
Code (PHP)
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO re_data (`position`, name, address, Education, major, Exp, sarary) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['education'], "text"),
GetSQLValueString($_POST['major'], "text"),
GetSQLValueString($_POST['exp'], "text"),
GetSQLValueString($_POST['sarary'], "text"));
mysql_select_db($database_data1, $data1);
$Result1 = mysql_query($insertSQL, $data1) or die(mysql_error());
$insertGoTo = "show.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
ให้เป็นแบบนี้
Code (PHP)
<?php require_once('Connections/data1.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 re_data (`position`, name, address, Education, major, Exp, sarary) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['position'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['education'], "text"),
GetSQLValueString($_POST['major'], "text"),
GetSQLValueString($_POST['exp'], "text"),
GetSQLValueString($_POST['sarary'], "text"));
mysql_select_db($database_data1, $data1);
$Result1 = mysql_query($insertSQL, $data1) or die(mysql_error());
$insertGoTo = "show.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_data1, $data1);
$query_Recordset1 = "SELECT name FROM re_data";
$Recordset1 = mysql_query($query_Recordset1, $data1) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!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=windows-874" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="602" border="1">
<tr>
<td colspan="2"><div align="center">
<p> </p>
<p><strong>สมัครงาน</strong></p>
<p> </p>
</div></td>
</tr>
<tr>
<td width="140"><strong>ตำแหน่ง</strong></td>
<td width="446"><strong>
<select name="position" id="position">
<option>เลือก</option>
<option>โปรแกรมเมอร์</option>
<option>นักวิชาการเกษตร</option>
<option>วิศวการยาง</option>
<option>จป วิชาชีพ</option>
</select>
</strong></td>
</tr>
<tr>
<td>ชื่อ-นามสกุล</td>
<td><label for="name2"></label>
<input name="name" type="text" /></td>
</tr>
<tr>
<td>ที่อยู่</td>
<td><label for="address2"></label>
<textarea name="address" id="address2" cols="45" rows="5"></textarea></td>
</tr>
<tr>
<td>ระดับการศึกษา</td>
<td><label for="education2"></label>
<select name="education" id="education2">
<option>ม.6</option>
<option>ปวช.</option>
<option>ปวส.</option>
<option>ปริญญาตรี</option>
<option>ปริญญาโท</option>
</select>
สาขา
<label for="major2"></label>
<input type="text" name="major" /></td>
</tr>
<tr>
<td>ประสบการณ์ทำงาน</td>
<td><label for="exp2"></label>
<textarea name="exp" id="exp2" cols="45" rows="5"></textarea></td>
</tr>
<tr>
<td>เงินเดือน</td>
<td><label for="sarary"></label>
<input type="text" name="sarary" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="save" id="save" value="บันทึก" />
<input type="reset" name="reset" id="reset" value="รีเฟรส" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
</body>
</html>
<?php
|
ประวัติการแก้ไข 2013-05-17 10:13:21
|
|
|
|
Date :
2013-05-17 10:11:41 |
By :
dekkuza |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอลคุงครับ เจอแล้ว อิๆๆๆ
|
|
|
|
|
Date :
2013-05-17 10:27:20 |
By :
dRufFy |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เดียวมีให้รบกวนอีกเยอะนะครับ อิๆๆๆ ปล.กินไปทำไป+เมาเลย 555+
|
|
|
|
|
Date :
2013-05-17 10:29:22 |
By :
dRufFy |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|