|
|
|
ส่งค่า จากการค้นหา มาเก็บไว้ หลาย ๆ ครั้งต่อกันได้รึเปล่าครับ |
|
|
|
|
|
|
|
ลองดูพวก UNION / UNION ALL ครับ
|
|
|
|
|
Date :
2013-08-05 15:04:52 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แนะนำ jquery เลยค่ะ
|
|
|
|
|
Date :
2013-08-05 15:14:17 |
By :
survivor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไฟล์แรกเป็นหน้ารับข้อมูลที่ได้จากกดปุ่มเลือก ทดสอบดูน่ะค่ะ
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<input type="text" name="searchText" id="searchText" /> <input type="button" value="ค้นหา" id="searchBtn" /><br />
<div id="searchResFrame" style="display:block;width:800px;height:200px;overflow:auto;"></div><br />
<table id="yourChoices" >
<tr><td>ลำดับ</td><td>สินค้า</td><td>ราคา</td></tr>
</table>
<script>
$("#searchBtn").click(function(){
$("div#searchResFrame").load("searchProduct.php",{"itemSearch":$("#searchText").val()});
});
</script>
searchProduct.php
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<table border="1">
<tr><td>ลำดับ</td><td>สินค้า</td><td>ราคา</td><td width="50">เลือก</td></tr>
<?php
//โค้ดติดต่อฐานข้อมูล
/*$i=1;
$sql = "select * from product where productname like "%{$_GET["itemSearch"]}%" ";
$res = mysql_query($sql) or die(mysql_error());
while($data = mysql_fetch_assoc($res)){
echo "<tr><td>$i</td><td>{$data["productname"]}</td><td>{$data["price"]}</td><td><input type=\"checkbox\" pname=\"{$data["productname"]}\" pprice=\"{$data["price"]}\" pid=\"{$data["pid"]}\" class=\"chooseItem\" /></td></tr>\n";
$i++;
}*/
?>
<tr><td>1</td><td>AAAAA</td><td>10</td><td><input type="checkbox" pname="AAAAA" pprice="10" pid="1" class="chooseItem" /></td></tr>
<tr><td>2</td><td>23AA</td><td>30</td><td><input type="checkbox" pname="23AA" pprice="30" pid="6" class="chooseItem" /></td></tr>
<tr><td>3</td><td>AA990</td><td>40</td><td><input type="checkbox" pname="AA990" pprice="40" pid="4" class="chooseItem" /></td></tr>
<tr><td>4</td><td>CVCVC9</td><td>20</td><td><input type="checkbox" pname="CVCVC9" pprice="20" pid="8" class="chooseItem" /></td></tr>
<tr><td>5</td><td>ABSOLUTE</td><td>100</td><td><input type="checkbox" pname="ABSOLUTE" pprice="100" pid="10" class="chooseItem" /></td></tr>
</table>
<script>
var pid,pprice,pname,current;
$("input:checkbox.chooseItem").click(function(){
pid = $(this).attr("pid");
pprice = $(this).attr("pprice");
pname = $(this).attr("pname");
current = $(this);
if(current.is(":checked")) {
$("table#yourChoices").append("<tr id='"+pid+"'><td></td><td>"+pname+"</td><td>"+pprice+"</td></tr>");
$("table#yourChoices tr:not(:first-child)").each(function(index){
$(this).find("td:first-child").text(++index);
});
}else{
$("table#yourChoices").find("tr[id="+pid+"]").remove();
$("table#yourChoices tr:not(:first-child)").each(function(index){
$(this).find("td:first-child").text(++index);
});
}
});
</script>
|
ประวัติการแก้ไข 2013-08-06 01:14:11 2013-08-06 01:22:58 2013-08-06 01:23:45
|
|
|
|
Date :
2013-08-06 01:12:09 |
By :
survivor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2013-08-06 05:33:17 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
โค้ดที่วางไว้ให้ ค้นหากี่ครั้งข้อมูลที่เลือกไว้ก็ไม่หายนี่ค่ะ
ลองเอาโค้ดที่ทำอยู่มาวางให้ดูด้วยจะดีกว่าค่ะ
ช่วยสมัครสมาชิกด้วยค่ะ
|
ประวัติการแก้ไข 2013-08-07 16:09:53
|
|
|
|
Date :
2013-08-07 16:06:44 |
By :
survivor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
โค๊ดทั้งหมด ครับ
Code (PHP)
<p>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<input type="text" name="searchText" id="searchText" /> <input type="button" value="ค้นหา" id="searchBtn" /><br />
<div id="searchResFrame" style="display:block;width:800px;height:200px;overflow:auto;"></div><br />
<table id="yourChoices" >
<tr><td>ลำดับ</td><td>สินค้า</td><td>ราคา</td></tr>
</table>
<p>
<script>
$("#searchBtn").click(function(){
$("div#searchResFrame").load("invoice_bin.php",{"itemSearch":$("#searchText").val()});
});
</script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<table border="1">
<tr><td>ลำดับ</td><td>สินค้า</td><td>ราคา</td><td width="50">เลือก</td></tr>
<?php
$i=1;
$sql = "SELECT * FROM `order`
WHERE idcode_pb like '%{$_GET['searchText']}%'";
$res = mysql_query($sql) or die(mysql_error());
while($data = mysql_fetch_assoc($res)){
if($_GET["searchText"] != "")
{
echo "<tr><td>$i</td><td>{$data[order_generation]}</td><td>{$data[order_size]}</td><td><input type=\"checkbox\" pname=\"{$data[order_generation]}\" pprice=\"{$data[order_size]}\" pid=\"{$i}\" class=\"chooseItem\" /></td></tr>\n";
$i++;
}
}
?>
</table>
<script>
var pid,pprice,pname,current;
$("input:checkbox.chooseItem").click(function(){
pid = $(this).attr("pid");
pprice = $(this).attr("pprice");
pname = $(this).attr("pname");
current = $(this);
if(current.is(":checked")) {
$("table#yourChoices").append("<tr id='"+pid+"'><td></td><td>"+pname+"</td><td>"+pprice+"</td></tr>");
$("table#yourChoices tr:not(:first-child)").each(function(index){
$(this).find("td:first-child").text(++index);
});
}else{
$("table#yourChoices").find("tr[id="+pid+"]").remove();
$("table#yourChoices tr:not(:first-child)").each(function(index){
$(this).find("td:first-child").text(++index);
});
}
});
</script>
|
|
|
|
|
Date :
2013-08-07 16:12:47 |
By :
Qut |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยจับภาพหน้าจอมาด้วยค่ะ จะได้เห็นภาพชัดๆว่าผิดเพี้ยนตรงจุดไหนบ้าง
ปล.ช่วยสมัครสมาชิกด้วยน่ะค่ะ
|
|
|
|
|
Date :
2013-08-07 16:35:21 |
By :
survivor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เย็นนี้ผมจะสมัคร ขอบคุณล่วงหน้า ครับ
|
|
|
|
|
Date :
2013-08-07 16:54:50 |
By :
Qut |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ค้นหา 4561 แล้วเลือกแล้ว 3 ตัว พอ ค้นหา 4562 ข้อมูลของ 4561 ก็หายไป ขอบคุณล่วงหน้า ครับ
|
|
|
|
|
Date :
2013-08-07 16:57:55 |
By :
Qut |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ในโค้ดส่วนอื่นที่ไม่ได้เอามาลงไว้ มีแท็ค form หรือปุ่ม submit หรือเปล่าค่ะ เพราะคิดว่าน่าจะเกิดการรีเฟรชหน้าจอตอนกดปุ่มค้นหาน่ะค่ะ
|
|
|
|
|
Date :
2013-08-07 16:59:53 |
By :
survivor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช่ครับ มี ปุ่ม submit ตอนนี้ผมลบไปแล้ว แต่ผลลัพธ์ที่ได้เปนแบบในรูปครับ ค้นหาไม่เจอข้อมูล แล้วก็ขึ้นอีกหน้า ซ้อนอยู่ข้างใน
(ลืม บอกไปครับ หน้านี้เป็นเป็น popup ครับ)
โค๊ดทั้งหมด ครับ
invoice_bin_search.php
Code (PHP)
<p>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<input type="text" name="searchText" id="searchText" /> <input type="button" value="ค้นหา" id="searchBtn" /><br />
<div id="searchResFrame" style="display:block;width:800px;height:200px;overflow:auto;"></div><br />
<table width="217" id="yourChoices" >
<tr><td width="67" align="center">ลำดับ</td><td width="81" align="center">สินค้า</td><td width="53" align="center">ราคา</td></tr>
</table>
<p>
<script>
$("#searchBtn").click(function(){
$("div#searchResFrame").load("invoice_bin_search.php",{"itemSearch":$("#searchText").val()});
});
</script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<table width="364" border="1">
<tr><td align="center">ลำดับ</td><td align="center">สินค้า</td><td align="center">ราคา</td><td width="50" align="center">เลือก</td></tr>
<?php
//โค้ดติดต่อฐานข้อมูล
$i=1;
$sql = "SELECT * FROM `order`
WHERE idcode_pb like '%{$_GET['searchText']}%'";
$res = mysql_query($sql) or die(mysql_error());
while($data = mysql_fetch_assoc($res)){
if($_GET["searchText"] != "")
{
echo "<tr><td>$i</td><td>{$data[order_generation]}</td><td>{$data[order_size]}</td><td><input type=\"checkbox\" pname=\"{$data[order_generation]}\" pprice=\"{$data[order_size]}\" pid=\"{$i}\" class=\"chooseItem\" /></td></tr>\n";
$i++;
}
}
?>
</table>
<script>
var pid,pprice,pname,current;
$("input:checkbox.chooseItem").click(function(){
pid = $(this).attr("pid");
pprice = $(this).attr("pprice");
pname = $(this).attr("pname");
current = $(this);
if(current.is(":checked")) {
$("table#yourChoices").append("<tr id='"+pid+"'><td></td><td>"+pname+"</td><td>"+pprice+"</td></tr>");
$("table#yourChoices tr:not(:first-child)").each(function(index){
$(this).find("td:first-child").text(++index);
});
}else{
$("table#yourChoices").find("tr[id="+pid+"]").remove();
$("table#yourChoices tr:not(:first-child)").each(function(index){
$(this).find("td:first-child").text(++index);
});
}
});
</script>
|
ประวัติการแก้ไข 2013-08-08 11:18:08 2013-08-08 11:22:08 2013-08-08 11:22:43 2013-08-08 11:26:31 2013-08-08 11:30:53
|
|
|
|
Date :
2013-08-08 11:14:14 |
By :
rock_rock |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทดลองดูน่ะค่ะ
invoice_bin_search.php
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<input type="text" name="searchText" id="searchText" /> <input type="button" value="ค้นหา" id="searchBtn" /><br />
<div id="searchResFrame" style="display:block;width:800px;height:200px;overflow:auto;"></div><br />
<table id="yourChoices" >
<tr><td>ลำดับ</td><td>สินค้า</td><td>ราคา</td></tr>
</table>
<script>
$("#searchBtn").click(function(){
$("div#searchResFrame").load("searchProduct.php",{"itemSearch":$("#searchText").val()});
});
</script>
searchProduct.php
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<table border="1">
<tr><td>ลำดับ</td><td>สินค้า</td><td>ราคา</td><td width="50">เลือก</td></tr>
<?php
//โค้ดติดต่อฐานข้อมูล
if($_GET["itemSearch"] != "")
{
$i=1;
$sql = "SELECT * FROM `order`
WHERE idcode_pb like '%{$_GET['itemSearch']}%'";
$res = mysql_query($sql) or die(mysql_error());
while($data = mysql_fetch_assoc($res)){
echo "<tr><td>$i</td><td>{$data["productname"]}</td><td>{$data["price"]}</td><td><input type=\"checkbox\" pname=\"{$data["productname"]}\" pprice=\"{$data["price"]}\" pid=\"{$data["pid"]}\" class=\"chooseItem\" /></td></tr>\n";
$i++;
}
}
?>
</table>
<script>
var pid,pprice,pname,current;
$("input:checkbox.chooseItem").click(function(){
pid = $(this).attr("pid");
pprice = $(this).attr("pprice");
pname = $(this).attr("pname");
current = $(this);
if(current.is(":checked")) {
$("table#yourChoices").append("<tr id='"+pid+"'><td></td><td>"+pname+"</td><td>"+pprice+"</td></tr>");
$("table#yourChoices tr:not(:first-child)").each(function(index){
$(this).find("td:first-child").text(++index);
});
}else{
$("table#yourChoices").find("tr[id="+pid+"]").remove();
$("table#yourChoices tr:not(:first-child)").each(function(index){
$(this).find("td:first-child").text(++index);
});
}
});
</script>
|
ประวัติการแก้ไข 2013-08-08 12:43:47 2013-08-08 12:45:52
|
|
|
|
Date :
2013-08-08 12:01:25 |
By :
survivor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตรงโค้ดติดต่อฐานข้อมูล ในบรรทัดที่ 6 ให้ใส่โค้ด mysql_connect , mysql_select_db ด้วยค่ะ
|
|
|
|
|
Date :
2013-08-08 12:03:40 |
By :
survivor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองแทรกโค้ดแบบนี้น่ะค่ะ
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<?php echo "<h1>{$_GET["itemSearch"]}</h1>"; ?>
<table border="1">
และ
$res = mysql_query($sql) or die(mysql_error());
echo $sql;
ในไฟล์ searchProduct.php แล้วจับภาพหน้าจอให้ดูด้วยค่ะ
|
ประวัติการแก้ไข 2013-08-08 16:23:19
|
|
|
|
Date :
2013-08-08 15:55:54 |
By :
survivor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เหมือนค่าไม่มา ครับ
searchProduct.php
Code (PHP)
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<?php echo "<h1>{$_GET['itemSearch']}</h1>"; ?>
<table border="1">
<tr><td>ลำดับ</td><td>สินค้า</td><td>ราคา</td><td width="50">เลือก</td></tr>
<?php
//โค้ดติดต่อฐานข้อมูล
//if($_GET["itemSearch"] != "")
//{
$i=1;
$sql = "SELECT * FROM `order`
WHERE idcode_pb like '%{$_GET['itemSearch']}%'";
$res = mysql_query($sql) or die(mysql_error());
while($data = mysql_fetch_assoc($res)){
echo "<tr><td>$i</td><td>{$data[order_generation]}</td><td>{$data[order_size]}</td><td><input type=\"checkbox\" pname=\"{$data[order_generation]}\" pprice=\"{$data[order_size]}\" pid=\"{$i}\" class=\"chooseItem\" /></td></tr>\n";
$i++;
}
//}
?>
</table>
<script>
var pid,pprice,pname,current;
$("input:checkbox.chooseItem").click(function(){
pid = $(this).attr("pid");
pprice = $(this).attr("pprice");
pname = $(this).attr("pname");
current = $(this);
if(current.is(":checked")) {
$("table#yourChoices").append("<tr id='"+pid+"'><td></td><td>"+pname+"</td><td>"+pprice+"</td></tr>");
$("table#yourChoices tr:not(:first-child)").each(function(index){
$(this).find("td:first-child").text(++index);
});
}else{
$("table#yourChoices").find("tr[id="+pid+"]").remove();
$("table#yourChoices tr:not(:first-child)").each(function(index){
$(this).find("td:first-child").text(++index);
});
}
});
</script>
|
|
|
|
|
Date :
2013-08-08 16:24:53 |
By :
rock_rock |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองเปลี่ยนจาก $_GET เป็น $_REQUEST
และ echo $sql; ดูด้วยค่ะ
|
|
|
|
|
Date :
2013-08-08 16:29:23 |
By :
survivor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ข้อมูลมันเป็น array เวลาจะแสดงผล ต้องอ้างอิง index ของมันด้วยนะครับ และเมื่อส่งแบบ POST ไปทำไมไม่รับ $_POST['']; ละครับ
Code (PHP)
<?=$_POST['pprice'][0]?>
<?=$_POST['pprice'][1]?>
หรือ
foreach($_POST['pprice'] as $value){
echo $value."</br>";
}
|
|
|
|
|
Date :
2013-08-09 10:09:32 |
By :
Manussawin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หน้าส่ง ๆ ได้ แล้ว ครับ เหลือน่ารักครับ error แบบนี้ครับ
Warning: Invalid argument supplied for foreach() in /home/ifbbphkq/domains/data.komfortflow.com/public_html/company_user/invoice_bin.php on line 268
ผมอยากให้หน้าจอออกมาเป็นแบบนี้ครับ เช่น ผมเลือกมา 1 รายการแล้วส่งค่ามาหน้า invoice_bin.php แล้ว ก็มีช่องให้กรอกข้อมูล พอกรอกเสร็จแล้ว ก็ บันทึกลงฐานข้อมูล ติดที่ว่า ตัว textfield ไม่วนตาม foreach ครับ ถ้าเราเลือก 5 รายการ textfield ก็มี 5 รายการประมาณนี้ครับ
|
ประวัติการแก้ไข 2013-08-09 14:09:41 2013-08-09 14:16:23
|
|
|
|
Date :
2013-08-09 14:08:48 |
By :
rock_rock |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
น่าจะเป็นแบบนี้มั้งค่ะ invoice_bin.php
<table width="621" border="1" align="center" cellspacing="0" bordercolor="#CCCCCC">
<tr class="gf">
<td width="111" align="center" valign="middle" bgcolor="#CCCCCC">สินค้า</td>
<td width="114" align="center" valign="middle" bgcolor="#CCCCCC">ราคา</td>
<td width="59" align="center" valign="middle" bgcolor="#CCCCCC">จำนวน</td>
<td width="59" align="center" valign="middle" bgcolor="#CCCCCC">จำนวนเหลือ</td>
<td width="59" align="center" valign="middle" bgcolor="#CCCCCC">จำนวนส่ง</td>
<td width="79" align="center" valign="middle" bgcolor="#CCCCCC">ราคา</td>
<td width="110" align="center" valign="middle" bgcolor="#CCCCCC">รวม</td>
</tr>
<?php
if(isset($_POST["pname"],$_POST["pprice"])){
foreach($_POST["pname"] as $key => $pnameVal){
?>
<tr>
<td align="center" valign="middle"><?=$pnameVal?>
</td>
<td align="center" valign="middle"><?=$_POST["pprice"][$key]?>
</td>
<td align="center" valign="middle">
<input name="textfield" type="text" id="textfield" size="5" />
</td>
<td align="center" valign="middle"><input name="textfield3" type="text" id="textfield3" size="5" />
</td>
<td align="center" valign="middle"><input name="textfield4" type="text" id="textfield4" size="5" />
</td>
<td align="center" valign="middle"><input name="textfield5" type="text" id="textfield5" size="5" />
</td>
<td align="center" valign="middle"><input name="textfield6" type="text" id="textfield6" size="5" />
</td>
</tr>
<?php
}
}
?>
</table>
|
|
|
|
|
Date :
2013-08-09 14:15:48 |
By :
survivor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมบันทึกลงฐานข้อมูลแล้ว ค่าลง แค่ค่าเดียวครับ ผมทำ 2 แบบ แบบแรก คือแบบนี้
invoice_bin.php
Code (PHP)
<form action='invoice_bin_in.php' method='post' name='form'>
<table width="621" height="1%" border="0" align="center" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td width="50" align="left" valign="middle" bgcolor="#FFFFFF" >ชื่อบริษัท<br /></td>
<td width="365" align="left" valign="top" bgcolor="#FFFFFF" ><input name="stock_name" type="text" id="stock_name" size="30" /></td>
<td width="200" rowspan="2" align="left" valign="top" bgcolor="#FFFFFF" ><table width="200" border="0" align="left" cellspacing="0">
<tr>
<td width="94" align="right" valign="baseline">เลขที่</td>
<td width="13"> </td>
<td width="87" align="left" valign="baseline">
<input name="stock_num_run" type="hidden" id="stock_num_run" value="<?=$num_run;?>" size="30" /></td>
</tr>
<tr>
<td align="right" valign="baseline">วันที่</td>
<td> </td>
<td align="left" valign="baseline"><? echo $stock_date=date('Y-m-d')?>
<input name="stock_date" type="hidden" id="stock_date" value="<?=$stock_date?>" size="30" /></td>
</tr>
</table></td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#FFFFFF" >
<img src="immage/delet_.jpg" width="19" height="19" />
</td>
<td align="left" valign="top" bgcolor="#FFFFFF" > </td>
</tr>
</table>
<table width="621" border="1" align="center" cellspacing="0" bordercolor="#CCCCCC">
<tr class="gf">
<td width="111" align="center" valign="middle" bgcolor="#CCCCCC">สินค้า</td>
<td width="114" align="center" valign="middle" bgcolor="#CCCCCC">ขนาด</td>
<td width="77" align="center" valign="middle" bgcolor="#CCCCCC">จำนวน</td>
<td width="66" align="center" valign="middle" bgcolor="#CCCCCC">จำนวนเหลือ</td>
<td width="53" align="center" valign="middle" bgcolor="#CCCCCC">จำนวนส่ง</td>
<td width="76" align="center" valign="middle" bgcolor="#CCCCCC">ราคา</td>
<td width="94" align="center" valign="middle" bgcolor="#CCCCCC">รวม</td>
</tr>
<?php
if(isset($_POST["pname"],$_POST["pprice"],$_POST["porder_ID"],$_POST["pmember"] ,$_POST["pidcode_pb"])){
foreach($_POST["pname"] as $key => $pnameVal){
?>
<tr>
<td align="center" valign="middle"><input name="stock_order_ID" type="hidden" id="stock_order_ID" value=" <?=$_POST["porder_ID"][$key]?>" size="30" />
<?=$_POST["porder_ID"][$key]?>
<input name="stock_order_generation" type="hidden" id="stock_order_generation" value=" <?=$pnameVal?>" size="30" />
<input name="stock_idcode_pb" type="hidden" id="stock_idcode_pb" value="<?=$_POST["pidcode_pb"][$key]?>" size="30" />
<?=$pnameVal?>
</td>
<td align="center" valign="middle"><strong>
<input name="stock_order_size" type="hidden" id="stock_order_size" value="<?=$_POST["pprice"][$key]?>" size="30" />
</strong>
<?=$order_member=$ar['order_member'][$key];?><?=$_POST["pprice"][$key]?>
</td>
<td align="center" valign="middle"><input name="stock_order_member" type="hidden" id="stock_order_member" value="<?=$_POST["pmember"][$key]?>" size="30" />
<?=$_POST["pmember"][$key]?> </td>
<td align="center" valign="middle"><input name="stock_order_member_rest" type="text" id="stock_order_member_rest" size="5" />
</td>
<td align="center" valign="middle"><input name="stock_order_member_send" type="text" id="stock_order_member_send" size="5" />
</td>
<td align="center" valign="middle"><input name="stock_price" type="text" id="stock_price" size="5" />
</td>
<td align="center" valign="middle"><input name="stock_price_sum" type="text" id="stock_price_sum" size="7" />
</td>
</tr>
<?php } } ?>
</table>
<input type="submit" name="button" id="button" value="Submit" />
</form>
invoice_bin_in.php
Code (PHP)
<?php
$stock_date=$_POST['stock_date'];
$stock_num_run=$_POST['stock_num_run'];
$stock_name=$_POST['stock_name'];
$stock_order_ID=$_POST['stock_order_ID'];
$stock_order_size=$_POST['stock_order_size'];
$stock_order_member=$_POST['stock_order_member'];
$stock_order_member_rest=$_POST['stock_order_member_rest'];
$stock_order_member_send=$_POST['stock_order_member_send'];
$stock_price=$_POST['stock_price'];
$stock_price_sum=$_POST['stock_price_sum'];
$stock_idcode_pb=$_POST['stock_idcode_pb'];
$insert="INSERT INTO `stock` (stock_id,stock_date,stock_num_run,stock_name,stock_order_ID,stock_order_size,stock_order_member, stock_order_member_rest, stock_order_member_send , stock_price, stock_price_sum,stock_idcode_pb)
VALUES ('','$stock_date' , '$stock_num_run' , '$stock_name' , '$stock_order_ID' , '$stock_order_size' , '$stock_order_member', '$stock_order_member_rest' , '$stock_order_member_send' , '$stock_price' , '$stock_price_sum','$stock_idcode_pb')";
$result=mysql_query($insert);
if($result){
mysql_query("COMMIT");
al("success!!");
redi3("invoice_bin.php");
}else{
echo mysql_error();
mysql_query("ROLLBACK");
al("not success!!");
redi3("javascript:history:back();");
}
?>
ส่วนแบบที่ 2 ไม่ ลง เกิด error ครับ
invoice_bin.php
Code (PHP)
<table width="600" height="225" border="0" align="center" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr>
<td width="613" height="222" align="center" valign="top">
<form action='invoice_bin_in.php' method='post' name='form'>
<table width="621" height="1%" border="0" align="center" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td width="50" align="left" valign="middle" bgcolor="#FFFFFF" >ชื่อบริษัท<br /></td>
<td width="365" align="left" valign="top" bgcolor="#FFFFFF" ><input name="stock_name[]" type="text" id="stock_name[]" size="30" /></td>
<td width="200" rowspan="2" align="left" valign="top" bgcolor="#FFFFFF" ><table width="200" border="0" align="left" cellspacing="0">
<tr>
<td width="94" align="right" valign="baseline">เลขที่</td>
<td width="13"> </td>
<td width="87" align="left" valign="baseline">
<input name="stock_num_run[]" type="hidden" id="stock_num_run[]" value="<?=$num_run;?>" size="30" /></td>
</tr>
<tr>
<td align="right" valign="baseline">วันที่</td>
<td> </td>
<td align="left" valign="baseline"><? echo $stock_date=date('Y-m-d')?>
<input name="stock_date[]" type="hidden" id="stock_date[]" value="<?=$stock_date?>" size="30" /></td>
</tr>
</table></td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#FFFFFF" >
<a href="javascript:popup('http://data.komfortflow.com/company_user/invoice_bin_search.php','',1200,560)" ><span class="style123"><span class="style89"><img border="0" alt="tc-621028" src="immage/pus.png" width="18" height="17" /></span></span></a> </td>
<td align="left" valign="top" bgcolor="#FFFFFF" > </td>
</tr>
</table>
<table width="621" border="1" align="center" cellspacing="0" bordercolor="#CCCCCC">
<tr class="gf">
<td width="111" align="center" valign="middle" bgcolor="#CCCCCC">รุ่นสินค้า</td>
<td width="114" align="center" valign="middle" bgcolor="#CCCCCC">ขนาด</td>
<td width="77" align="center" valign="middle" bgcolor="#CCCCCC">จำนวน</td>
<td width="66" align="center" valign="middle" bgcolor="#CCCCCC">จำนวนเหลือ</td>
<td width="53" align="center" valign="middle" bgcolor="#CCCCCC">จำนวนส่ง</td>
<td width="76" align="center" valign="middle" bgcolor="#CCCCCC">ราคา</td>
<td width="94" align="center" valign="middle" bgcolor="#CCCCCC">รวม</td>
</tr>
<?php
if(isset($_POST["pname"],$_POST["pprice"],$_POST["porder_ID"],$_POST["pmember"] ,$_POST["pidcode_pb"])){
foreach($_POST["pname"] as $key => $pnameVal){
?>
<tr>
<td align="center" valign="middle"><input name="stock_order_ID[]" type="hidden" id="stock_order_ID[]" value=" <?=$_POST["porder_ID"][$key]?>" size="30" />
<input name="stock_order_generation[]" type="hidden" id="stock_order_generation[]" value=" <?=$pnameVal?>" size="30" />
<input name="stock_idcode_pb[]" type="hidden" id="stock_idcode_pb[]" value="<?=$_POST["pidcode_pb"][$key]?>" size="30" />
<?=$pnameVal?>
</td>
<td align="center" valign="middle"><strong>
<input name="stock_order_size[]" type="hidden" id="stock_order_size[]" value="<?=$_POST["pprice"][$key]?>" size="30" />
</strong>
<?=$order_member=$ar['order_member'];?><?=$_POST["pprice"][$key]?>
</td>
<td align="center" valign="middle"><input name="stock_order_member[]" type="hidden" id="stock_order_member[]" value="<?=$_POST["pmember"][$key]?>" size="30" />
<?=$_POST["pmember"][$key]?> </td>
<td align="center" valign="middle"><input name="stock_order_member_rest[]" type="text" id="stock_order_member_rest[]" size="5" />
</td>
<td align="center" valign="middle"><input name="stock_order_member_send[]" type="text" id="stock_order_member_send[]" size="5" />
</td>
<td align="center" valign="middle"><input name="stock_price[]" type="text" id="stock_price[]" size="5" />
</td>
<td align="center" valign="middle"><input name="stock_price_sum[]" type="text" id="stock_price_sum[]" size="7" />
</td>
</tr>
<?php } } ?>
</table>
<br />
<br />
<input type="submit" name="button" id="button" value="บันทึก"/>
</form></td>
</tr>
<tr>
<td height="1" align="left" valign="top">
</td>
</tr>
<tr>
<td height="2" align="left" valign="middle">
</td>
</tr>
</table>
invoice_bin_in.php
Code (PHP)
if(isset($_POST["stock_date"],$_POST["stock_num_run"],$_POST["stock_name"],$_POST["stock_order_ID"] ,$_POST["stock_order_size"] ,$_POST["stock_order_member"] ,$_POST["stock_order_member_rest"] ,$_POST["stock_order_member_send"] ,$_POST["stock_price"] ,$_POST["stock_price_sum"] ,$_POST["stock_idcode_pb"])){
foreach($_POST["pname"] as $key => $pnameVal){
$insert = "INSERT INTO `stock` (stock_id,stock_date,stock_num_run,stock_name,stock_order_ID,stock_order_size,stock_order_member, stock_order_member_rest, stock_order_member_send , stock_price, stock_price_sum,stock_idcode_pb)
VALUES ('".$_POST[stock_date][$key].",".$_POST[stock_num_run][$key].",".$_POST[stock_name][$key].",".$_POST[stock_order_ID][$key].",".$_POST[stock_order_size][$key].",".$_POST[stock_order_member][$key].",".$_POST[stock_order_member_rest][$key].",".$_POST[stock_order_member_send][$key].",".$_POST[stock_price][$key].",".$_POST[stock_price_sum][$key].",".$_POST[stock_idcode_pb][$key]."')";
$result=mysql_query($insert);
if($result){
mysql_query("COMMIT");
al("success!!");
redi3("invoice_bin.php");
}else{
echo mysql_error();
mysql_query("ROLLBACK");
al("not success!!");
redi3("javascript:history:back();");
}
}
}
|
|
|
|
|
Date :
2013-08-10 16:34:01 |
By :
rock_rock |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
รบกวนช่วยดูโค๊ดให้หน่อย ครับ ว่าทำแบบไหน ถึงจะลงฐานข้อมูล หลาย ๆ แถว ตอนนี้ทำแบบแรก ลงแถวเดียว ครับ
|
|
|
|
|
Date :
2013-08-13 14:37:50 |
By :
rock_rock |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Quote:<form action='invoice_bin_in.php' method='post' name='form'>
<table width="621" height="1%" border="0" align="center" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td width="50" align="left" valign="middle" bgcolor="#FFFFFF" >ชื่อบริษัท<br /></td>
<td width="365" align="left" valign="top" bgcolor="#FFFFFF" ><input name="stock_name" type="text" id="stock_name" size="30" /></td>
<td width="200" rowspan="2" align="left" valign="top" bgcolor="#FFFFFF" ><table width="200" border="0" align="left" cellspacing="0">
<tr>
<td width="94" align="right" valign="baseline">เลขที่</td>
<td width="13"> </td>
<td width="87" align="left" valign="baseline">
<input name="stock_num_run" type="hidden" id="stock_num_run" value="<?=$num_run;?>" size="30" /></td>
</tr>
<tr>
<td align="right" valign="baseline">วันที่</td>
<td> </td>
<td align="left" valign="baseline"><? echo $stock_date=date('Y-m-d')?>
<input name="stock_date" type="hidden" id="stock_date" value="<?=$stock_date?>" size="30" /></td>
</tr>
</table></td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#FFFFFF" >
<img src="immage/delet_.jpg" width="19" height="19" />
</td>
<td align="left" valign="top" bgcolor="#FFFFFF" > </td>
</tr>
</table>
<table width="621" border="1" align="center" cellspacing="0" bordercolor="#CCCCCC">
<tr class="gf">
<td width="111" align="center" valign="middle" bgcolor="#CCCCCC">สินค้า</td>
<td width="114" align="center" valign="middle" bgcolor="#CCCCCC">ขนาด</td>
<td width="77" align="center" valign="middle" bgcolor="#CCCCCC">จำนวน</td>
<td width="66" align="center" valign="middle" bgcolor="#CCCCCC">จำนวนเหลือ</td>
<td width="53" align="center" valign="middle" bgcolor="#CCCCCC">จำนวนส่ง</td>
<td width="76" align="center" valign="middle" bgcolor="#CCCCCC">ราคา</td>
<td width="94" align="center" valign="middle" bgcolor="#CCCCCC">รวม</td>
</tr>
<?php
if(isset($_POST["pname"],$_POST["pprice"],$_POST["porder_ID"],$_POST["pmember"] ,$_POST["pidcode_pb"])){
foreach($_POST["pname"] as $key => $pnameVal){
?>
<tr>
<td align="center" valign="middle"><input name="stock_order_ID[]" type="hidden" id="stock_order_ID" value=" <?=$_POST["porder_ID"][$key]?>" size="30" />
<?=$_POST["porder_ID"][$key]?>
<input name="stock_order_generation[]" type="hidden" id="stock_order_generation" value=" <?=$pnameVal?>" size="30" />
<input name="stock_idcode_pb[]" type="hidden" id="stock_idcode_pb" value="<?=$_POST["pidcode_pb"][$key]?>" size="30" />
<?=$pnameVal?>
</td>
<td align="center" valign="middle"><strong>
<input name="stock_order_size[]" type="hidden" id="stock_order_size" value="<?=$_POST["pprice"][$key]?>" size="30" />
</strong>
<?=$order_member=$ar['order_member'][$key];?><?=$_POST["pprice"][$key]?>
</td>
<td align="center" valign="middle"><input name="stock_order_member[]" type="hidden" id="stock_order_member" value="<?=$_POST["pmember"][$key]?>" size="30" />
<?=$_POST["pmember"][$key]?> </td>
<td align="center" valign="middle"><input name="stock_order_member_rest[]" type="text" id="stock_order_member_rest" size="5" />
</td>
<td align="center" valign="middle"><input name="stock_order_member_send[]" type="text" id="stock_order_member_send" size="5" />
</td>
<td align="center" valign="middle"><input name="stock_price[]" type="text" id="stock_price" size="5" />
</td>
<td align="center" valign="middle"><input name="stock_price_sum[]" type="text" id="stock_price_sum" size="7" />
</td>
</tr>
<?php } } ?>
</table>
<input type="submit" name="button" id="button" value="Submit" />
</form>
Quote:<?php
$stock_date=$_POST['stock_date'];
$stock_num_run=$_POST['stock_num_run'];
$stock_name=$_POST['stock_name'];
// array type
$stock_order_ID=$_POST['stock_order_ID'];
/*
$stock_order_size=$_POST['stock_order_size'];
$stock_order_member=$_POST['stock_order_member'];
$stock_order_member_rest=$_POST['stock_order_member_rest'];
$stock_order_member_send=$_POST['stock_order_member_send'];
$stock_price=$_POST['stock_price'];
$stock_price_sum=$_POST['stock_price_sum'];
$stock_idcode_pb=$_POST['stock_idcode_pb'];
*/
foreach($_POST['stock_order_ID'] as $key => $stock_order_ID){
$insert="INSERT INTO `stock` (stock_id,stock_date,stock_num_run,stock_name,stock_order_ID,stock_order_size,stock_order_member, stock_order_member_rest, stock_order_member_send , stock_price, stock_price_sum,stock_idcode_pb)
VALUES ('','$stock_date' , '$stock_num_run' , '$stock_name' , '$stock_order_ID' , '{$_POST['stock_order_size'][$key]}' , '{$_POST['stock_order_member'][$key]}', '{$_POST['stock_order_member_rest'][$key]}' , '{$_POST['stock_order_member_send'][$key]}' , '{$_POST['stock_price'][$key]}' , '{$_POST['stock_price_sum'][$key]}','{$_POST['stock_idcode_pb'][$key]}' )";
$result=mysql_query($insert);
if($result){
mysql_query("COMMIT");
al("success!!");
redi3("invoice_bin.php");
}else{
echo mysql_error();
mysql_query("ROLLBACK");
al("not success!!");
redi3("javascript:history:back();");
}
}
?>
|
|
|
|
|
Date :
2013-08-13 14:57:56 |
By :
survivor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากๆ ครับ คุณ LittleLovely +1
|
|
|
|
|
Date :
2013-08-14 13:18:11 |
By :
rock_rock |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|