|
|
|
ajax insert มีปัญหา กดปุ่มบันทึกแล้วไม่เพิ่มข้อมูล |
|
|
|
|
|
|
|
3.php
<?
session_start();
include"connect.php";
$strSQL = "SELECT * FROM user u ,prefix p WHERE u.user_id = '".$_SESSION['user_id']."' AND u.prefix = p.prefix_id";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
$fullname = $objResult['prefix_name'].$objResult['fname']." ".$objResult['lname'];
?>
<html>
<head>
<title>บันทึกใบ PO รถจักรยานยนต์</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body {
background-image: url(image/bg.jpg);
background-repeat: repeat-x;
font-weight: bold;
}
</style>
</head>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(Mode) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = '4.php';
var pmeters = "&tpo_id=" + encodeURI( document.getElementById("txtpo_id").value) +
"&tdate_receive=" + encodeURI( document.getElementById("txtdate_receive").value ) +
"&tbranch=" + encodeURI( document.getElementById("txtbranch").value ) +
"&treceive_name=" + encodeURI( document.getElementById("txtreceive_name").value ) +
"&tmachine_id=" + encodeURI( document.getElementById("txtmachine_id").value ) +
"&tchassis_id=" + encodeURI( document.getElementById("txtchassis_id").value ) +
"&tbrand=" + encodeURI( document.getElementById("txtbrand").value ) +
"&tclass=" + encodeURI( document.getElementById("txtclass").value ) +
"&ttype=" + encodeURI( document.getElementById("txttype").value ) +
"&tcolor=" + encodeURI( document.getElementById("txtcolor").value ) +
"&tplate=" + encodeURI( document.getElementById("txtplate").value ) +
"&tprovince=" + encodeURI( document.getElementById("txtprovince").value ) +
"&tregis_tear=" + encodeURI( document.getElementById("txtregis_year").value ) +
"&tsell=" + encodeURI( document.getElementById("txtsell").value ) +
"&tbuy=" + encodeURI( document.getElementById("txtbuy").value ) +
"&tMode=" + Mode;
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-lengtd", pmeters.lengtd);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
document.getElementById("txtpo_id").value = '';
document.getElementById("txtdate_receive").value = '';
document.getElementById("txtbranch").value = '';
document.getElementById("txtreceive_name").value = '';
document.getElementById("txtmachine_id").value = '';
document.getElementById("txtchassis_id").value = '';
document.getElementById("txtbrand").value = '';
document.getElementById("txtclass").value = '';
document.getElementById("txttype").value = '';
document.getElementById("txtcolor").value = '';
document.getElementById("txtplate").value = '';
document.getElementById("txtprovince").value = '';
document.getElementById("txtregis_year").value = '';
document.getElementById("txtsell").value = '';
document.getElementById("txtbuy").value = '';
}
}
}
</script>
<link href="main_style.css" rel="stylesheet" type="text/css">
<body Onload="JavaScript:doCallAjax('LIST');">
<!--<table width="1292" style="font-size: 50px; text-align: center; color: #FFF; font-weight: bold;" bordercolor="#000066" >
<tr bgcolor="#66CCFF">
<td><img src="image/logo.png" width="74" height="71">...ศูนย์ซ่อมรถมือสอง...</td>
</tr>
</table>-->
<? include "menu.php"; ?>
<? include "s1.php"; ?>
<? include "script.php"; ?>
<? include "pref.php"; ?>
<form name="frmMain">
<div id="right_block">
<table width="940" style="font-size: 13px; text-align: left;">
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("motor");
$strSQL = "SELECT * FROM pref WHERE 1 ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($objQuery);
$PO = $objResult["keyname"];
$po_id = $PO.'-'.$strNextSeq;
?>
<tr>
<td> </td>
<td> </td>
<td>เลขที่ใบรับรถ</td>
<td><input type="text" id="txtpo_id" name="txtpo_id" value="<?=$po_id;?>" class="tbl_box7"></td>
<td align="right">วันที่รับรถ</td>
<td><input type="text" name="txtdate_receive" id="txtdate_receive"></td>
</tr>
<tr>
<td align="right">รับรถจากสาขา</td>
<td colspan="3" align="left"><select name="txtbranch" id="txtbranch">
<option value="">------------ เลือก -----------</option>
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("motor");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
$strSQL = "SELECT * FROM branch ORDER BY branch_id ASC";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["branch_no"];?>" size="14">
<?=$objResuut["branch_no"]." - ".$objResuut["branch_name"];?>
</option>
<?
}
?>
</select></td>
<td align="right">ผู้รับรถ</td>
<td><input type="text" name="txtdate_receive" id="txtdate_receive" value="<?=$fullname;?>"></td>
</tr>
<tr>
<td colspan="6"><hr></td>
</tr>
<tr>
<td widtd="91" align="right">ยี่ห้อ</td>
<td>
<select id="txtbrand" name="txtbrand">
<option value="">------------ เลือก -----------</option>
<?php
$result = mysql_query("
SELECT
brand_id,
brand_name
FROM
brand
ORDER BY CONVERT(brand_id USING TIS620) ASC;
");
while($row = mysql_fetch_assoc($result))
{
echo '<option value="', $row['brand_id'], '">', $row['brand_name'],'</option>';
}
?>
</select>
</td>
<td widtd="91" align="right">รุ่น</td>
<td>
<select id="txtclass" name="txtclass">
<option value="">------------ เลือก -----------</option>
</select><span id="waitClass"></span>
</td>
<td widtd="98" align="right">แบบ</td>
<td>
<select id="txttype" name="txttype">
<option value="">------------ เลือก -----------</option>
</select><span id="waitType"></span>
</td>
</tr>
<tr>
<td align="right">สี</td>
<td>
<select name="txtcolor" id="txtcolor">
<option value="">------------ เลือก -----------</option>
<?
$strSQL = "SELECT * FROM color ORDER BY color_id ASC";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["color_id"];?>"><?=$objResuut["color_name"];?></option>
<?
}
?>
</select>
</td>
<td widtd="91" align="right">เลขเครื่อง</td>
<td><input type="text" name="txtmachine_id" id="txtmachine_id"></td>
<td widtd="98" align="right">เลขถัง</td>
<td><input type="text" name="txtchassis_id" id="txtchassis_id"></td>
</tr>
<tr>
<td widtd="198" align="right">ป้ายทะเบียน</td>
<td><input type="text" name="txtplate" id="txtplate"></td>
<td widtd="198" align="right">จังหวัด</td>
<td><input type="text" name="txtprovince" id="txtprovince"></td>
<td widtd="97" align="right"> ปีที่จดทะเบียน</td>
<td><select name="txtregis_year" id="txtregis_year">
<option value="">------------ เลือก -----------</option>
<option value="2545">2545</option>
<option value="2546">2546</option>
<option value="2547">2547</option>
<option value="2548">2548</option>
<option value="2549">2549</option>
<option value="2550">2550</option>
<option value="2551">2551</option>
<option value="2552">2552</option>
<option value="2553">2553</option>
<option value="2554">2554</option>
<option value="2555">2555</option>
<option value="2556">2556</option>
</select>
</td>
</tr>
<tr>
<td widtd="59" align="right"> </td>
<td > </td>
<td widtd="59" align="right">ราคาขาย</td>
<td ><input type="text" name="txtsell" id="txtsell" OnChange="JavaScript:chkNum(this)"></td>
<td widtd="71" align="right">ราคาซื้อ</td>
<td><input type="text" name="txtbuy" id="txtbuy" OnChange="JavaScript:chkNum(this)"></td>
</tr>
</table>
</div>
<div align="center">
<input type="button" name="btnAdd" id="btnAdd" value="เพิ่มข้อมูล" OnClick="JavaScript:doCallAjax('ADD');">
</div>
<br><br>
<span id="mySpan"></span>
</form>
4.php
<?php
$strMode = $_POST["tMode"];
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("motor");
//ตัด comma ราคาซื้อ-ขาย
$buy = $_POST["tbuy"];
$sell = $_POST["tsell"];
$b = substr($buy,0,2);
$buy = substr($buy,3,3);
$s = substr($sell,0,2);
$sell = substr($sell,3,3);
//แปลงวันที่
$date_receive = $_POST["tdate_receive"];
$dd = substr($date_receive,0,2);
$mm = substr($date_receive,3,2);
$yy = substr($date_receive,6,4);
$yy = $yy-543;
$date_receive = $yy.'-'.$mm.'-'.$dd;
?>
<?
if($strMode == "ADD")
{
$strSQL = "INSERT INTO stock_receive_motor ";
$strSQL .="(branch_no,po_id,machine_id,chassis_id,brand,class,type,color,plate,province,regis_year,buy,sell) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["tbranch"]."','".$_POST["tpo_id"]."','".$_POST["tmachine_id"]."','".$_POST["tchassis_id"]."' ";
$strSQL .=",'".$_POST["tbrand"]."','".$_POST["tclass"]."','".$_POST["ttype"]."','".$_POST["tcolor"]."','".$_POST["tplate"]."' ";
$strSQL .=",'".$_POST["tprovince"]."' ,'".$_POST["tregis_year"]."','$buy','$sell') ";
$objQuery = mysql_query($strSQL);
}
{
$strSQL = "INSERT INTO stock_mas ";
$strSQL .="(branch_id,po_id,date_receive,receive_name) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["tbranch"]."','".$_POST["tpo_id"]."','$date_receive','".$_POST["treceive_name"]."') ";
$objQuery = mysql_query($strSQL);
}
?>
</div>
<?
mysql_close($objConnect);
?>
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2013-05-06 09:04:19
|
|
|
|
|
Date :
2013-05-06 09:03:00 |
By :
lookpla26 |
View :
1296 |
Reply :
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ต้องการให้ตัวเลข PO แสดงใน text box แต่ทำไมมันไม่แสดงอ้ะค้ะ
ที่มาร์คสีเหลืองไว้แค่แสดงออกมาดูอ้ะค้ะ แต่พอกำหนด value ใน textbox มันกลับไม่ขึ้น
|
ประวัติการแก้ไข 2013-05-06 09:14:25 2013-05-06 09:15:39
|
|
|
|
Date :
2013-05-06 09:09:46 |
By :
lookpla26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยังไม่ขึ้น โหย....
|
|
|
|
|
Date :
2013-05-06 10:25:30 |
By :
lookpla26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำไมข้างบนมี
include"connect.php";
แล้วข้างล่างต้องมี
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
ด้วยครับ ไม่ใช่ตัวเดียวกันเหรอ
แล้วอีกอย่าง มี 2 ที่เลย
$objResult = mysql_fetch_array($objQuery);
มีทั้งบนทั้งล่าง แล้วจะรู้ได้ไงว่า ใช้ตัวไหน
ลอง
Code (PHP)
echo $po_id = $PO.'-'.$strNextSeq; ดูว่ามีค่ารึป่าว
|
|
|
|
|
Date :
2013-05-06 11:29:09 |
By :
teez1232002 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect.php
มาให้ดูหน่อย
|
|
|
|
|
Date :
2013-05-06 11:41:26 |
By :
teez1232002 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หน้าจอหลักค่ะ
**ปัญหาคือ**
- ต้องการให้เลขที่บิลคืนค่ากลับมาหลังจากที่เพิ่มรถคันแรกไปแล้ว เพื่อที่จะเพิ่มรถคันที่สองจากเลขที่บิลเดิม
- ให้แสดงเลขที่บิลอัตโนมัติโดยไม่ต้องคีย์
add_store.php
<? include "menu.php"; ?>
<? include "s1.php"; ?>
<? include "script.php"; ?>
<? include "pref.php"; ?>
<html>
<head>
<title>บันทึกใบ PO รถจักรยานยนต์</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body {
background-image: url(image/bg.jpg);
background-repeat: repeat-x;
font-weight: bold;
}
</style>
</head>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(Mode) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = '4.php';
var pmeters = "&tpo_id=" + encodeURI( document.getElementById("txtpo_id").value) +
"&tdate_receive=" + encodeURI( document.getElementById("txtdate_receive").value ) +
"&tbranch=" + encodeURI( document.getElementById("txtbranch").value ) +
"&treceive_name=" + encodeURI( document.getElementById("txtreceive_name").value ) +
"&tmachine_id=" + encodeURI( document.getElementById("txtmachine_id").value ) +
"&tchassis_id=" + encodeURI( document.getElementById("txtchassis_id").value ) +
"&tbrand=" + encodeURI( document.getElementById("txtbrand").value ) +
"&tclass=" + encodeURI( document.getElementById("txtclass").value ) +
"&ttype=" + encodeURI( document.getElementById("txttype").value ) +
"&tcolor=" + encodeURI( document.getElementById("txtcolor").value ) +
"&tplate=" + encodeURI( document.getElementById("txtplate").value ) +
"&tprovince=" + encodeURI( document.getElementById("txtprovince").value ) +
"&tregis_year=" + encodeURI( document.getElementById("txtregis_year").value ) +
"&tsell=" + encodeURI( document.getElementById("txtsell").value ) +
"&tbuy=" + encodeURI( document.getElementById("txtbuy").value ) +
"&tMode=" + Mode;
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-lengtd", pmeters.lengtd);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
document.getElementById("txtpo_id").value = '';
document.getElementById("txtdate_receive").value = '';
document.getElementById("txtbranch").value = '';
document.getElementById("txtreceive_name").value = '';
document.getElementById("txtmachine_id").value = '';
document.getElementById("txtchassis_id").value = '';
document.getElementById("txtbrand").value = '';
document.getElementById("txtclass").value = '';
document.getElementById("txttype").value = '';
document.getElementById("txtcolor").value = '';
document.getElementById("txtplate").value = '';
document.getElementById("txtprovince").value = '';
document.getElementById("txtregis_year").value = '';
document.getElementById("txtsell").value = '';
document.getElementById("txtbuy").value = '';
}
}
}
</script>
<? include "connect.php"; ?>
<link href="main_style.css" rel="stylesheet" type="text/css">
<body Onload="JavaScript:doCallAjax('LIST');">
<form name="frmMain">
<div id="right_block">
<table width="940" style="font-size: 13px; text-align: left;">
<tr>
<td> </td>
<td> </td>
<td>เลขที่ใบรับรถ</td>
<td><input type="text" id="txtpo_id" name="txtpo_id" value="<?=$po_id;?>"></td>
<td align="right">วันที่รับรถ</td>
<td><input type="text" name="txtdate_receive" id="txtdate_receive"></td>
</tr>
<tr>
<td align="right">รับรถจากสาขา</td>
<td colspan="3" align="left">
<select name="txtbranch" id="txtbranch">
<option value="">------------ เลือก -----------</option>
<?
$strSQL = "SELECT * FROM branch ORDER BY branch_id ASC";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["branch_no"];?>" size="14">
<?=$objResuut["branch_no"]." - ".$objResuut["branch_name"];?>
</option>
<?
}
?>
</select>
</td>
<td align="right">ผู้รับรถ</td>
<td><input type="text" name="txtreceive_name" id="txtreceive_name" value="<?=$fullname;?>"></td>
</tr>
<tr>
<td colspan="6"><hr></td>
</tr>
<tr>
<td widtd="91" align="right">ยี่ห้อ</td>
<td>
<select id="txtbrand" name="txtbrand">
<option value="">------------ เลือก -----------</option>
<?php
$result = mysql_query("
SELECT
brand_id,
brand_name
FROM
brand
ORDER BY CONVERT(brand_id USING TIS620) ASC;
");
while($row = mysql_fetch_assoc($result))
{
echo '<option value="', $row['brand_id'], '">', $row['brand_name'],'</option>';
}
?>
</select>
</td>
<td widtd="91" align="right">รุ่น</td>
<td>
<select id="txtclass" name="txtclass">
<option value="">------------ เลือก -----------</option>
</select><span id="waitClass"></span>
</td>
<td widtd="98" align="right">แบบ</td>
<td>
<select id="txttype" name="txttype">
<option value="">------------ เลือก -----------</option>
</select><span id="waitType"></span>
</td>
</tr>
<tr>
<td align="right">สี</td>
<td>
<select name="txtcolor" id="txtcolor">
<option value="">------------ เลือก -----------</option>
<?
$strSQL = "SELECT * FROM color ORDER BY color_id ASC";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["color_id"];?>"><?=$objResuut["color_name"];?></option>
<?
}
?>
</select>
</td>
<td widtd="91" align="right">เลขเครื่อง</td>
<td><input type="text" name="txtmachine_id" id="txtmachine_id"></td>
<td widtd="98" align="right">เลขถัง</td>
<td><input type="text" name="txtchassis_id" id="txtchassis_id"></td>
</tr>
<tr>
<td widtd="198" align="right">ป้ายทะเบียน</td>
<td><input type="text" name="txtplate" id="txtplate"></td>
<td widtd="198" align="right">จังหวัด</td>
<td>
<select name="txtprovince" id="txtprovince">
<option value="">------------ เลือก -----------</option>
<?
$strSQL = "SELECT * FROM province ORDER BY province_id ASC";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["province_id"];?>"><?=$objResuut["province_name"];?></option>
<?
}
?>
</select>
</td>
<td widtd="97" align="right"> ปีที่จดทะเบียน</td>
<td><select name="txtregis_year" id="txtregis_year">
<option value="">------------ เลือก -----------</option>
<option value="2545">2545</option>
<option value="2546">2546</option>
<option value="2547">2547</option>
<option value="2548">2548</option>
<option value="2549">2549</option>
<option value="2550">2550</option>
<option value="2551">2551</option>
<option value="2552">2552</option>
<option value="2553">2553</option>
<option value="2554">2554</option>
<option value="2555">2555</option>
<option value="2556">2556</option>
</select>
</td>
</tr>
<tr>
<td widtd="59" align="right"> </td>
<td > </td>
<td widtd="59" align="right">ราคาขาย</td>
<td ><input type="text" name="txtsell" id="txtsell" OnChange="JavaScript:chkNum(this)"></td>
<td widtd="71" align="right">ราคาซื้อ</td>
<td><input type="text" name="txtbuy" id="txtbuy" OnChange="JavaScript:chkNum(this)"></td>
</tr>
</table>
</div>
<div align="center">
<input type="button" name="btnAdd" id="btnAdd" value="เพิ่มข้อมูล" OnClick="JavaScript:doCallAjax('ADD');">
</div>
<br><br>
<span id="mySpan"></span>
</form>
4.php
<?php
$strMode = $_POST["tMode"];
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("motor");
$buy = $_POST["tbuy"];
$sell = $_POST["tsell"];
$sell = (int)$sell;
$buy = (int)$buy;
//แปลงวันที่
$date_receive = $_POST["tdate_receive"];
$dd = substr($date_receive,0,2);
$mm = substr($date_receive,3,2);
$yy = substr($date_receive,6,4);
$yy = $yy-543;
$date_receive = $yy.'-'.$mm.'-'.$dd;
?>
<?
if($strMode == "ADD")
{
$strSQL = "INSERT INTO stock_receive_motor ";
$strSQL .="(branch_no,po_id,machine_id,chassis_id,brand,class,type,color,plate,province,regis_year,buy,sell) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["tbranch"]."','".$_POST["tpo_id"]."','".$_POST["tmachine_id"]."','".$_POST["tchassis_id"]."' ";
$strSQL .=",'".$_POST["tbrand"]."','".$_POST["tclass"]."','".$_POST["ttype"]."','".$_POST["tcolor"]."','".$_POST["tplate"]."' ";
$strSQL .=",'".$_POST["tprovince"]."' ,'".$_POST["tregis_year"]."','$buy','$sell') ";
$objQuery = mysql_query($strSQL);
}
{
$strSQL = "INSERT INTO stock_mas ";
$strSQL .="(branch_id,po_id,date_receive,receive_name) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["tbranch"]."','".$_POST["tpo_id"]."','$date_receive','".$_POST["treceive_name"]."') ";
$objQuery = mysql_query($strSQL);
}
$strSQL = "SELECT * FROM stock_receive_motor s
INNER JOIN brand b ON s.brand = b.brand_id
INNER JOIN class c ON s.class = c.class_id
INNER JOIN type d ON s.type = d.type_id
WHERE machine_id LIKE '%".$strSearch."%' ORDER BY machine_id ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$num_row = mysql_num_rows($objQuery);
?>
<link href="main_style.css" rel="stylesheet" type="text/css">
<link href="script.php" rel="stylesheet" type="text/css" />
<div style="margin-left:320px;">
<table width="898" style="font-size:14px" border="1" >
<tr bgcolor="#CCCCCC">
<th width="50" height="34"> <div align="center">ลำดับ</div></th>
<th width="91"> <div align="center">เลขเครื่อง</div></th>
<th width="98"> <div align="center">เลขถัง</div></th>
<th width="98"> <div align="center">ยี่ห้อ</div></th>
<th width="98"> <div align="center">รุ่น</div></th>
<th width="59"> <div align="center">ราคาซื้อ</div></th>
</tr>
<?
$i;
while($objResult = mysql_fetch_array($objQuery))
{
$i++;
$buy = $objResult["buy"];
$total = $total + $buy;
?>
<tr bgcolor="#FFFFFF">
<td height="30" align="center"><?=$i;?>.</td>
<td><?=$objResult["machine_id"];?></td>
<td><?=$objResult["chassis_id"];?></td>
<td><?=$objResult["brand_name"];?></td>
<td><?=$objResult["type_name"];?></td>
<td><?=$objResult["buy"];?></td>
</tr>
<?
}
?>
<tr bgcolor="#CCCCCC">
<th colspan="4">จำนวนรถ ::<u> <?=$num_row;?> </u> ::คัน</div></th>
<th width="98"> <div align="center">รวมเป็นเงิน</div></th>
<th width="59"> <div align="center"><?=$total;?></div></th>
</tr>
</table>
</div>
<?
mysql_close($objConnect);
?>
|
|
|
|
|
Date :
2013-05-06 11:48:08 |
By :
lookpla26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
document.getElementById("txtpo_id").value = ''; /// เอาออก
4.php
mysql_close($objConnect); /// เอาออก
|
|
|
|
|
Date :
2013-05-06 11:50:20 |
By :
teez1232002 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_store.php
ถ้า echo ค่า $po_id ออกมามันแสดงค่า
แต่พอใส่ textbox มันไม่แสดงค่าค่ะ
<td>เลขที่ใบรับรถ</td>
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("motor");
$strSQL = "SELECT * FROM pref WHERE 1 ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($objQuery);
$PO = $objResult["keyname"];
$po_id = $PO.'-'.$strNextSeq;
?>
<td><input type="text" id="txtpo_id" name="txtpo_id" value="<?=$po_id;?>"></td>
|
|
|
|
|
Date :
2013-05-06 11:56:05 |
By :
lookpla26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้าพูดถึงเรื่อง Code ไม่ผิดครับ
ลองแล้วออกปรกติ ถ้า PLA บอกว่า มันมา
|
|
|
|
|
Date :
2013-05-06 12:02:43 |
By :
teez1232002 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่แน่ใจว่ามันจะเกียวกับ AJAX รึเปล่าเพราะว่า ใช้การ insert แบบ AJAX
ตอนที่เรากด refresh เลขที่บิลจะแสดงใน textbox ประมาณ 1 วิ แล้วก็จะหายไป
|
|
|
|
|
Date :
2013-05-06 12:08:56 |
By :
lookpla26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
วิธี debug เมื่อส่ง request ไปแล้ว ในหน้าที่เรียกไปลอง
print_r($_POST);
แล้วใน javascript ลอง alert(resposeText); ออกมาดู ดูซิว่ามัน ส่ง post ไปหรือเปล่า ตัวแปรต่างๆ มีค่าหรือไม่
ผมว่าเปลี่ยนมาใช้ jQuery ชีวิตจะไม่ลำบากขนาดนี้
|
|
|
|
|
Date :
2013-05-06 13:25:06 |
By :
ikikkok |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print_r($_POST);
Array ( [tdate_receive] => [tbranch] => [treceive_name] => [tmachine_id] => [tchassis_id] => [tbrand] => [tclass] => [ttype] => [tcolor] => [tplate] => [tprovince] => [tregis_year] => [tsell] => [tbuy] => [tMode] => LIST )
อะไรไม่รู้ค่ะ
|
|
|
|
|
Date :
2013-05-06 13:52:26 |
By :
lookpla26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เปลี่ยนเป็น insert ธรรมดาแล้วกัน เเล้วค่อยส่งค่ากลับมา
|
|
|
|
|
Date :
2013-05-06 14:16:18 |
By :
lookpla26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|