|
|
|
ช่วยแก้โค้ดให้หน่อยครับ insert ไม่ยอมเข้า DB access ครับ |
|
|
|
|
|
|
|
ทำไงดีครับ ช่วยแก้โค้ดให้ที มันไม่ยอมเข้า DB อ่ะครับ
Code (PHP)
<?php ob_start();
include 'connect.php';
$conn->open($msaccdb);
?>
<!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>Manage CIName</title>
<script type="text/javascript" src="javascriptfile/jquery.js"></script>
<script type="text/javascript" src="javascriptfile/jquery.rsv.js"></script>
<script type="text/javascript" src="javascriptfile/jquery.nyroModal.custom.js"></script>
<script type="text/javascript" src="javascriptfile/jqueryui.js"></script>
<link rel="stylesheet" type="text/css" href="cssfile/setbody.css" />
<link rel="stylesheet" type="text/css" href="cssfile/nyroModal.css" />
<link rel="stylesheet" type="text/css" href="cssfile/redmond/jqueryuiredmond.css" />
<script type="text/javascript">
$(function(){
$("#Search_CIName").autocomplete({
source: "search_ci2.php",
minLength: 3
});
$('button,:button,:submit,#new_btn').button();
$('#ci_date').datepicker({
changeMonth: true,
changeYear: true
});
});
$(function(){
$("#empname").autocomplete({
source: "search_emp_auto.php",
minLength: 4
});
});
$(function(){
$('.linkcen').nyroModal({
sizes: { // Size information
minW: 450, // minimum width
minH: 430 // minimum height
}
});
});
$(function(){
$("#form_search_ci").RSV({
errorFieldClass: "errorField",
displayType: "alert-one",
rules: [
// "required,Search_CIName,กรุณาใส่เลข CIName No.",
"digits_only,Search_CINameใส่ตัวเลขเท่านั้น"
]
});
});
$(function(){
$("#form_newcen,#form_editcen").RSV({
errorFieldClass: "errorField",
displayType: "alert-one",
rules: [
"required,CIName,กรุณาใส่เลข CIName No.",
"digits_only,CIName,ใส่ตัวเลขเท่านั้น",
]
});
});
$(function(){
$('#edit_con').click(function(){
if ($('[name="radiosel"]:checked').val() != undefined)
{
$(window.location).attr('href', 'CIName.php?Mod=edit&ID_CIName='+$("input:radio:checked").val());
}
});
});
$(function(){
$('#del_con').click(function(){
if ($('[name="radiosel"]:checked').val() != undefined)
{
if(confirm('Confirm Delete?')==true)
{
$(window.location).attr('href', 'CIName.php?Mod=del&ID_CIName='+$("input:radio:checked").val());
}
}
});
});
</script>
<style type="text/css">
.errorField {
background-color: #CC0000;
color: #FFFF00;
}
.ui-autocomplete {
max-height: 300px;
overflow-y: auto;
/* prevent horizontal scrollbar */
overflow-x: hidden;
/* add padding to account for vertical scrollbar */
padding-right: 20px;
}
/* IE 6 doesn't support max-height
* we use height instead, but this forces the menu to always be this tall
*/
* html .ui-autocomplete {
height: 300px;
}
#field-table tr td{ padding-top:10px;}
select{ width:155px;}
</style>
</head>
<body>
<div align="center" >
<h1>Manage CIName</h1>
<form action="" method="get" name="form_search_ci" id="form_search_ci">
<div>
<p class="ui-widget">
<b>ค้นหา CIName No.</b>
<input name="Search_ci" type="text" id="Search_ci" />
<input type="submit" name = "submit_search" id = "submit_search" value="ค้นหา" />
</p>
</div>
</form>
</div>
<div align="center">
<table>
<tr>
<td width="125">
<a href="?mode=new" id="new_btn">Create CIName</a> </td>
<td width="48"><input name="edit_con" id="edit_con" type="button" value="EDIT" /></td>
<td width="59"><input name="del_con" id="del_con" type="button" value="DELETE" /></td>
</tr>
</table>
</div>
<p>
</table>
<br />
</p>
<div align="right">
<button name="Submit" type="button" value="back" onclick="history.back()"> <font size="3"><b>Back</b></font> </button>
</div>
<?php
if($_GET['mode_']=="add"){
$ciname = $_POST['id_ciname'];
$status_ci = $_POST['id_status_ci'];
$contract = $_POST['contract_no'];
$describtion = $_POST['eq_type'];
$serial_no= $_POST['serial_no'];
$tag_number= $_POST['tag_number'];
$product= $_POST['id_brand'];
$model_version = $_POST['spec'];
$function_owner = $_POST['id_function_owner'];
$function_usage = $_POST['id_function_usage'];
$user= $_POST['Name_Surname'];
$ext = $_POST['ext'];
$region = $_POST['id_region'];
$sitegroup = $_POST['id_site_group'];
$site = $_POST['id_site'];
$building = $_POST['id_building'];
$floor = $_POST['id_floor'];
$room = $_POST['room'];
$ci_date = $_POST['ci_date'];
$summary = $_POST['summary'];
if($status=="")
$status = 0;
$column = "
CIName, Model_Version, Contract_No, Describtion, Serial_no, Tag_Number, Product_Name, Status_CI, Function_Owner, Function_Usage, User_Name, Ext, Region, Sitegroup, Site, Building, Floor, Room, CIDate, Summary ";
$values = " '$ciname','$Model_Version','$contract',
'$describtion','$serial_no','$tag_number'
,'$product','$status_ci','$function_owner','$function_usage','$user','$ext','$region',
'$sitegroup','$site','$building','$floor','$room','$ci_date','$summary'";
//echo ">> ".$ci_date;
$str12 = "INSERT INTO tb_CIName ($column)
VALUES ($values)";
//$str1 = "INSERT INTO tb_CIName ($column)
$new_conn2 = new COM("ADODB.Recordset");
$new_conn2->open($str12,$conn, 1, 3);
$new_conn2->close();
//echo $str1;
}
if($_GET['mode']=="new"){
?>
<div>
<form action="CIName.php?Mod=new&mode_=add" method="post">
<fieldset class="ui-widget ui-widget-content">
<legend><b>CI Name</b></legend>
<table width="551" align="center" class="ui-widget ui-widget-content">
<tr>
<td width="106">CIName</td>
<td width="155"><input name="id_ciname" type="text" /></td>
<td width="109">Status CI</td>
<td width="161"><select name="id_status_ci" >
<?php
$sql_pur = "select * from tb_Status_CI";
$Rec->open($sql_pur, $conn, 1, 3);
while (!$Rec->EOF)
{
?>
<option value="<?php echo $Rec->Fields['Status_CI_Name']->Value;?>"><?php echo $Rec->Fields['Status_CI_Name']->Value;?></option>
<?php
$Rec->MoveNext();
}
$Rec->close();
?>
</select></td>
</table>
</fieldset>
<fieldset class="ui-widget ui-widget-content">
<legend><b>Contract Information</b></legend>
<table width="548" align="center" class="ui-widget ui-widget-content">
<tr>
<td width="105">Contract No. </td>
<td width="158" nowrap="nowrap"><select name="contract_no" id="contract_no" class="ui-widget ui-widget-content" onchange="javascritp:location='CIName.php?mode=new&conNO='+this.value">
<?php if($_GET["conNO"]=="")
{
?> <option value="">กรุณาเลือกสัญญา.</option>
<?php }else{
$sql_get = "select * from tb_Contract where ID_Contract = ".$_GET["conNO"]." ";
$Rec->open($sql_get, $conn, 1, 3);
$conNO_value = $Rec->Fields['Contract_No']->Value;
$Rec->close();
?> <option value="<?php echo $_GET["conNO"]; ?>"><?php echo $conNO_value; ?></option>
<?php }
?>
<?php
$sql_pur = "select * from tb_Contract";
$Rec->open($sql_pur, $conn, 1, 3);
while (!$Rec->EOF)
{
?>
<option value="<?php echo $Rec->Fields['ID_Contract']->Value;?>"><?php echo $Rec->Fields['Contract_No']->Value;?></option>
<?php
$Rec->MoveNext();
}
$Rec->close();
?>
</select> </td>
<td width="105">Describtion </td>
<td width="160"td nowrap="nowrap">
<?php
if($_GET["conNO"]!="")
{
?> <select name="eq_type" id="eq_type" class="ui-widget ui-widget-content">
<option value="">กรุณาเลือกชนิดอุปกรณ์</option>
<?php $sql_pur = "select * from tb_Equipment where ID_Contract = ".$_GET["conNO"]." ";
$Rec->open($sql_pur, $conn, 1, 3);
while (!$Rec->EOF)
{
$show_equiment = "select * from tb_Equipment_Type where ID_Equipment_Type = ".$Rec->Fields['ID_Equipment_Type']->Value." ";
$new_rec = new COM("ADODB.Recordset");
$new_rec->open($show_equiment,$conn, 1, 3);
$show_ = $new_rec->Fields['Equipment_Type']->Value;
$new_rec->close();
?> <option value="<?php echo $Rec->Fields['ID_Equipment_Type']->Value;?>"><?php echo $show_; ?></option>
<?php $Rec->MoveNext();
}
$Rec->close();
?>
</select>
<?php
}
?> </td>
</tr>
<tr>
</table>
</fieldset>
<fieldset class="ui-widget ui-widget-content">
<legend><b>CI Information</b></legend>
<table align="center" class="ui-widget ui-widget-content">
<tr>
<td width="110">Serial No </td>
<td width="155"><input name="serial_no" type="text" /></td>
<td width="102">Tag Number </td>
<td width="168"><input name="tag_number" type="text" /></td>
</tr>
<tr>
<td>Product </td>
<td width="160"td nowrap="nowrap">
<?php
if($_GET["conNO"]!="")
{
?>
<select name="id_brand" id="id_brand" class="ui-widget ui-widget-content">
<option value="">-</option>
<?php $sql_pur = "select * from tb_Equipment where ID_Contract = ".$_GET["conNO"]." ";
$Rec->open($sql_pur, $conn, 1, 3);
while (!$Rec->EOF)
{
$show_equiment = "select * from tb_Brand where ID_Brand = ".$Rec->Fields['ID_Brand']->Value." ";
$new_rec = new COM("ADODB.Recordset");
$new_rec->open($show_equiment,$conn, 1, 3);
$show_ = $new_rec->Fields['Brand']->Value;
$new_rec->close();
?>
<option value="<?php echo $Rec->Fields['ID_Brand']->Value;?>"><?php echo $show_; ?></option>
<?php $Rec->MoveNext();
}
$Rec->close();
?>
</select>
<?php
}
?> </td>
<td>Model/Version </td>
<td width="160"td nowrap="nowrap">
<?php
if($_GET["conNO"]!="")
{
?>
<select name="spec" id="spec" class="ui-widget ui-widget-content">
<option value="">-</option>
<?php $sql_pur = "select * from tb_Equipment where ID_Contract = ".$_GET["conNO"]." ";
$Rec->open($sql_pur, $conn, 1, 3);
while (!$Rec->EOF)
{
$show_equiment = "select * from tb_Equipment where ID_Equipment = ".$Rec->Fields['ID_Equipment']->Value." ";
$new_rec = new COM("ADODB.Recordset");
$new_rec->open($show_equiment,$conn, 1, 3);
$show_ = $new_rec->Fields['Spec']->Value;
$new_rec->close();
?>
<option value="<?php echo $Rec->Fields['ID_Equipment']->Value;?>"><?php echo $show_; ?></option>
<?php $Rec->MoveNext();
}
$Rec->close();
?>
</select>
<?php
}
?> </td>
</tr>
<tr>
</table>
</fieldset>
<fieldset class="ui-widget ui-widget-content">
<legend><b>User Information</b></legend>
<table align="center" class="ui-widget ui-widget-content">
<tr>
<td width="114">Function Owner </td>
<td width="145"><select id="id_function_owner" name="id_function_owner">
<option value="">-</option>
<?php
$sql_pur = "select * from tb_Function";
$Rec->open($sql_pur, $conn, 1, 3);
while (!$Rec->EOF)
{
?>
<option value="<?php echo $Rec->Fields['Function_Name']->Value;?>"><?php echo $Rec->Fields['Function_Name']->Value;?></option>
<?php
$Rec->MoveNext();
}
$Rec->close();
?>
</select> </td>
<td width="113">Function Usage </td>
<td width="158"><input name="id_function_usage" type="text" /></td>
</tr>
<tr>
<td>User Name </td>
<td><input name="Name_Surname" type="text" /></td>
<td>Ext. </td>
<td><input name="ext" type="text" /></td>
</table>
</fieldset>
<fieldset class="ui-widget ui-widget-content">
<legend><b>Location Installation</b></legend>
<table width="551" align="center" class="ui-widget ui-widget-content">
<tr>
<td width="105">Region </td>
<td width="160"><select id="id_region" name="id_region">
<option value="">-</option>
<?php
$sql_pur = "select * from tb_Region";
$Rec->open($sql_pur, $conn, 1, 3);
while (!$Rec->EOF)
{
?>
<option value="<?php echo $Rec->Fields['Region']->Value;?>"><?php echo $Rec->Fields['Region']->Value;?></option>
<?php
$Rec->MoveNext();
}
$Rec->close();
?>
</select> </td>
<td width="111">Sitegroup </td>
<td width="155"><select id="id_site_group" name="id_site_group">
<option value="">-</option>
<?php
$sql_pur = "select * from tb_site_group";
$Rec->open($sql_pur, $conn, 1, 3);
while (!$Rec->EOF)
{
?>
<option value="<?php echo $Rec->Fields['Site_Group']->Value;?>"><?php echo $Rec->Fields['Site_Group']->Value;?></option>
<?php
$Rec->MoveNext();
}
$Rec->close();
?>
</select> </td>
</tr>
<tr>
<td>Site </td>
<td><select id="id_site" name="id_site">
<option value="">-</option>
<?php
$sql_pur = "select * from tb_site";
$Rec->open($sql_pur, $conn, 1, 3);
while (!$Rec->EOF)
{
?>
<option value="<?php echo $Rec->Fields['Site']->Value;?>"><?php echo $Rec->Fields['Site']->Value;?></option>
<?php
$Rec->MoveNext();
}
$Rec->close();
?>
</select> </td>
<td>Building </td>
<td><select id="id_building" name="id_building">
<option value="">-</option>
<?php
$sql_pur = "select * from tb_site";
$Rec->open($sql_pur, $conn, 1, 3);
while (!$Rec->EOF)
{
?>
<option value="<?php echo $Rec->Fields['Building']->Value;?>"><?php echo $Rec->Fields['Building']->Value;?></option>
<?php
$Rec->MoveNext();
}
$Rec->close();
?>
</select> </td>
</tr>
<tr>
<td>floor </td>
<td><select id="id_floor" name="id_floor">
<option value="">-</option>
<?php
$sql_pur = "select * from tb_site";
$Rec->open($sql_pur, $conn, 1, 3);
while (!$Rec->EOF)
{
?>
<option value="<?php echo $Rec->Fields['Floor']->Value;?>"><?php echo $Rec->Fields['Floor']->Value;?></option>
<?php
$Rec->MoveNext();
}
$Rec->close();
?>
</select> </td>
<td>Room </td>
<td><input name="room" type="text" /></td>
</tr>
</table>
</fieldset>
<fieldset class="ui-widget ui-widget-content">
<legend><b> Work Info </b></legend>
<table width="548" align="center" class="ui-widget ui-widget-content">
<tr>
<td width="103" align="left"><span class="style11">Date </span></td>
<td width="155"><input type="text" id="ci_date" name="ci_date" readonly="readonly" /></td>
<td width="119">Summary</td>
<td width="151"><input name="summary" type="text" /></td>
</tr>
</table>
</fieldset>
<br />
<div align="center">
<input name="submit_cost" id="submit_cost" type="submit" value="SAVE" />
</div>
</form>
</div>
<?php }?>
</body>
</html>
Tag : PHP, Ms Access, jQuery, Report Others, Web (ASP.NET), J#
|
|
|
|
|
|
Date :
2011-09-08 11:12:10 |
By :
CiizeN |
View :
821 |
Reply :
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ติดปัญหาอยู่ที่ imsert เข้า Db ครับ
แล้ว
Code (PHP)
<select name="id_brand" id="id_brand" class="ui-widget ui-widget-content">
<option value="">-</option>
<?php $sql_pur = "select * from tb_Equipment where ID_Contract = ".$_GET["conNO"]." ";
$Rec->open($sql_pur, $conn, 1, 3);
while (!$Rec->EOF)
{
$show_equiment = "select * from tb_Brand where ID_Brand = ".$Rec->Fields['ID_Brand']->Value." ";
$new_rec = new COM("ADODB.Recordset");
$new_rec->open($show_equiment,$conn, 1, 3);
$show_ = $new_rec->Fields['Brand']->Value;
$new_rec->close();
?>
<option value="<?php echo $Rec->Fields['ID_Brand']->Value;?>"><?php echo $show_; ?></option>
<?php $Rec->MoveNext();
}
$Rec->close();
?>
</select>
<?php
}
?>
ตรงนี้ Get ไม่เข้า db
|
|
|
|
|
Date :
2011-09-08 11:49:46 |
By :
ผู้ช่วยโลก |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$column = "
CIName, Model_Version, Contract_No, Describtion, Serial_no, Tag_Number, Product_Name, Status_CI, Function_Owner, Function_Usage, User_Name, Ext, Region, Sitegroup, Site, Building, Floor, Room, CIDate, Summary ";
$values = " '$ciname','$Model_Version','$contract',
'$describtion','$serial_no','$tag_number'
,'$product','$status_ci','$function_owner','$function_usage','$user','$ext','$region',
'$sitegroup','$site','$building','$floor','$room','$ci_date','$summary'";
//echo ">> ".$ci_date;
$str12 = "INSERT INTO tb_CIName ($column)
VALUES ($values)";
//$str1 = "INSERT INTO tb_CIName ($column)
$new_conn2 = new COM("ADODB.Recordset");
$new_conn2->open($str12,$conn, 1, 3);
$new_conn2->close();
//echo $str1;
}
การ Insert ไม่ได้ใช้ execute เหรอครับ
Code (PHP)
$new_conn2->execute($str12);
$new_conn2->close();
Go to : PHP ADO Add/Insert Record
|
|
|
|
|
Date :
2011-09-08 16:15:38 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมไม่ค่อยเข้าจัยครับ
|
|
|
|
|
Date :
2011-09-13 11:08:04 |
By :
CiizeN |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
การ Insert ไม่ได้ใช้ execute เหรอครับ
- ไม่ได้ execute ครับ
แล้วจะแก้ยังไง อ่ะครับ
ช่วยแนะนำหน่อยครับ ท่านwebmaster
|
|
|
|
|
Date :
2011-09-13 11:12:05 |
By :
CiizeN |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตามตัวอย่าง Link ครับ
|
|
|
|
|
Date :
2011-09-13 11:18:24 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณเป็นอย่างสูง ครับ ท่าน Webmaster
|
|
|
|
|
Date :
2011-09-13 11:24:52 |
By :
CiizeN |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|