|
|
|
ไม่สามารถ อัพข้อมูลที่ได้จาก listmenu ลง MySQL ได้ |
|
|
|
|
|
|
|
พอดีได้ Code ที่ได้มีการแจกจากที่นี้ผมเลยลองเปลี่ยนช่องข้อมูลจาก Textbox มาเป็น listmenu (STATUS)แล้วมันไม่สามารถ อัพข้อมูลที่ได้จาก listmenu ลง MySQL ได้
Code (PHP)
<?php require_once('../Connections/IT.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_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE addjob SET name=%s, datepicker=%s, `time`=%s, department=%s, piority=%s, subject=%s, problem=%s, details=%s, `comment`=%s, status=%s, email=%s WHERE id=%s",
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['datepicker'], "date"),
GetSQLValueString($_POST['time'], "text"),
GetSQLValueString($_POST['department'], "text"),
GetSQLValueString($_POST['piority'], "text"),
GetSQLValueString($_POST['subject'], "text"),
GetSQLValueString($_POST['problem'], "text"),
GetSQLValueString($_POST['details'], "text"),
GetSQLValueString($_POST['comment'], "text"),
GetSQLValueString($_POST['status'], "text"),
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($_POST['email'], "text"));
mysql_select_db($database_IT, $IT);
$Result1 = mysql_query($updateSQL, $IT) or die(mysql_error());
$updateGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_EAD = "-1";
if (isset($_GET['id'])) {
$colname_EAD = $_GET['id'];
}
mysql_select_db($database_IT, $IT);
$query_EAD = sprintf("SELECT * FROM addjob WHERE id = %s ORDER BY id DESC", GetSQLValueString($colname_EAD, "int"));
$EAD = mysql_query($query_EAD, $IT) or die(mysql_error());
$row_EAD = mysql_fetch_assoc($EAD);
$totalRows_EAD = mysql_num_rows($EAD);
?>
<!DOCTYPE html>
<tml lang="en">
<head>
<meta charset="utf-8">
<title>Edit your Ticket</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<script type="text/javascript">
function Nxtpage(){
var r=confirm ('Are you sure?');
if(r==true){
window.localtion="admin_index.php";
}
else{
return false;
}
}
</script>
<!-- Le styles -->
<link href="assets/css/bootstrap.css" rel="stylesheet">
<style type="text/css">
/* Sticky footer styles
-------------------------------------------------- */
html, body {
height: 100%;/* The html and body elements cannot have any padding or margin. */
}
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto !important;
height: 100%;
/* Negative indent footer by it's height */
margin: 0 auto -60px;
}
/* Set the fixed height of the footer here */
#push, #footer {
height: 60px;
}
#footer {
background-color: #f5f5f5;
}
/* Lastly, apply responsive CSS fixes as necessary */
@media (max-width: 767px) {
#footer {
margin-left: -20px;
margin-right: -20px;
padding-left: 20px;
padding-right: 20px;
}
}
/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */
#wrap > .container {
padding-top: 60px;
}
.container .credit {
margin: 20px 0;
}
code {
font-size: 80%;
}
</style>
<link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="../assets/js/html5shiv.js"></script>
<![endif]-->
<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="assets/ico/favicon.png">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="css/jquery-ui.css">
<script src="js/jquery-1.10.2.js"></script>
<script src="js/jquery-ui.js"></script>
<script>
$(function() {
$( "#datepicker" ).datepicker({dateFormat:'yy-mm-dd'});
});
</script>
</head>
<body background="images/1180422460.gif">
<!-- Part 1: Wrap all page content here -->
<div id="wrap">
<!-- Fixed navbar -->
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
<a class="brand" href="#">ROL Service :: Edit your Ticket</a>
<div class="nav-collapse collapse">
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
</div>
<p></p>
<br>
<?
$date = date("d-m-Y");
$time = date("H:i");
?>
</p>
<br>
<table width="100%" border="0">
<tr>
<td width="240" height="34" align="left"><img src="images/logo_ROL.png" width="450" height="50"></td>
<td width="753" align="center"><p><strong><img src="http://www.ufocool.com/images/flag/thailand.gif"> Edit your Ticket</strong><strong> <img src="http://www.ufocool.com/images/flag/thailand.gif"></strong></p></td>
<td width="329" align="center"><strong>
<button type="button" class="btn btn-success"><i class="icon-calendar"></i> Date :: Time : <?php echo $date." / ".$time;?></strong></button></td>
</tr>
</table>
<script src="assets/js/bootstrap-transition.js"></script>
<script src="assets/js/bootstrap-alert.js"></script>
<script src="assets/js/bootstrap-modal.js"></script>
<script src="assets/js/bootstrap-dropdown.js"></script>
<script src="assets/js/bootstrap-scrollspy.js"></script>
<script src="assets/js/bootstrap-tab.js"></script>
<script src="assets/js/bootstrap-tooltip.js"></script>
<script src="assets/js/bootstrap-popover.js"></script>
<script src="assets/js/bootstrap-button.js"></script>
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>
<script src="js/bootstrap.min.js"></script>
</p>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td height="24" align="left" nowrap><strong><i class="icon-user"></i> Name</strong></td>
<td><strong><i class="icon-flag"></i> Email</strong></td>
</tr>
<tr valign="baseline">
<td nowrap align="left"><input type="text" name="name" value="<?php echo htmlentities($row_EAD['name'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
<td><input type="text" name="mail" value="<?php echo htmlentities($row_EAD['email'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td height="22" align="left" nowrap><strong><i class="icon-calendar"></i> Date </strong></td>
<td><strong><i class="icon-wrench"></i> Piority</strong></td>
</tr>
<tr valign="baseline">
<td nowrap align="left"><input type="text" name="datepicker" id="datepicker" value="<?php echo htmlentities($row_EAD['datepicker'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
<td><input type="text" name="piority" value="<?php echo htmlentities($row_EAD['piority'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td height="22" align="left" nowrap><strong><i class="icon-time"></i> Time</strong></td>
<td><strong><i class="icon-file"></i> Problem</strong></td>
</tr>
<tr valign="baseline">
<td nowrap align="left"><input type="text" name="time" value="<?php echo htmlentities($row_EAD['time'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
<td><input type="text" name="problem" value="<?php echo htmlentities($row_EAD['problem'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td height="22" align="left" nowrap><strong><i class="icon-home"></i> Department</strong></td>
<td><strong>Subject</strong></td>
</tr>
<tr valign="baseline">
<td nowrap align="left"><input type="text" name="department" value="<?php echo htmlentities($row_EAD['department'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
<td><input type="text" name="subject" value="<?php echo htmlentities($row_EAD['subject'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td height="22" align="left" nowrap><strong><i class="icon-book"></i> Details</strong></td>
<td> </td>
</tr>
<tr valign="baseline">
<td colspan="2" align="left" nowrap><input type="text" class="mana" name="details" value="<?php echo htmlentities($row_EAD['details'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="left"> </td>
<td> </td>
</tr>
<tr valign="baseline">
<td height="22" align="left" nowrap><strong><i class="icon-comment"></i> Comment</strong></td>
<td> </td>
</tr>
<tr valign="baseline">
<td colspan="2" align="left" nowrap><input type="text" name="comment" class="mana" value="<?php echo htmlentities($row_EAD['comment'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td height="22" align="left" nowrap><strong><i class="icon-time"></i> Status</strong></td>
<td> </td>
</tr>
<tr valign="baseline">
<td nowrap align="left"><label for="select">
<select name="status" id="status">
<option value="<?php echo htmlentities($row_EAD['status'], ENT_COMPAT, 'utf-8'); ?>"></option>
<option value="Open">Open</option>
<option value="Pending">Pending</option>
<option value="Inprogress">Inprogress</option>
<option value="Close">Close</option>
</select>
</label></td>
<?php /*?><td><input type="text" name="status" value="<?php echo htmlentities($row_EAD['status'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td><?php */?>
</tr>
<tr valign="baseline">
<td colspan="2" align="left" nowrap>
<button type="submit" class="btn btn-success" ><i class="icon-upload"></i> Save </button>
<a href="index.php">
<button type="button" class="btn btn-danger" ><i class="icon-remove"></i> Cancel </button>
</a>
</td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="id" value="<?php echo $row_EAD['id']; ?>">
</form>
</body>
</html><?php
mysql_free_result($EAD);
?>
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2016-09-08 13:41:15
|
|
|
|
|
Date :
2016-09-08 12:15:52 |
By :
karurub |
View :
804 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
รูปแบบการเขียนและความถนัดของแต่ละคนต่างกัน ต้องรอสมาชิกท่านอื่น ที่ทำงานเชื่อมต่อฐานข้อมูลผ่าน dream ครับ...
แต่ถ้าไม่รีบอยากให้ศึกษาการทำงานแยกจากกัน
php mysql css html
เพราะมือใหม่ใช้ Dw หรือ สถาบันสอน Dw หรือ ทำตามหนังสือ มันก็จะดูงงๆ ลองศึกษาพื้นฐาน
insert select update delete โดยพื้นฐาน php ก่อนครับ แล้วมันจะใส่เข้าใจเวลาเอาไปร่วมกับ html
|
|
|
|
|
Date :
2016-09-08 14:51:09 |
By :
apisitp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนนี้แก้ให้ในส่วนของ Listbox อัพเดทข้อมูลลง MySQL ได้แล้ว แต่งงตรงที่ หลังจากที่มีการ Update แล้วข้อมูล Email ถูกลบออกไปจาก MySQL
Code (PHP)
<?php require_once('../Connections/IT.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_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE addjob SET name=%s, datepicker=%s, `time`=%s, department=%s, piority=%s, subject=%s, problem=%s, details=%s, `comment`=%s, status=%s, email=%s WHERE id=%s",
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['datepicker'], "date"),
GetSQLValueString($_POST['time'], "text"),
GetSQLValueString($_POST['department'], "text"),
GetSQLValueString($_POST['piority'], "text"),
GetSQLValueString($_POST['subject'], "text"),
GetSQLValueString($_POST['problem'], "text"),
GetSQLValueString($_POST['details'], "text"),
GetSQLValueString($_POST['comment'], "text"),
GetSQLValueString($_POST['status'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_IT, $IT);
$Result1 = mysql_query($updateSQL, $IT) or die(mysql_error());
$updateGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_EAD = "-1";
if (isset($_GET['id'])) {
$colname_EAD = $_GET['id'];
}
mysql_select_db($database_IT, $IT);
$query_EAD = sprintf("SELECT * FROM addjob WHERE id = %s ORDER BY id DESC", GetSQLValueString($colname_EAD, "int"));
$EAD = mysql_query($query_EAD, $IT) or die(mysql_error());
$row_EAD = mysql_fetch_assoc($EAD);
$totalRows_EAD = mysql_num_rows($EAD);
?>
|
|
|
|
|
Date :
2016-09-08 17:54:05 |
By :
karurub |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แก้ได้แล้วครับ ประกาศชื่อผิด
ขอบคุณทุกคนครับ
|
|
|
|
|
Date :
2016-09-12 13:41:06 |
By :
karurub |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|