Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ขอความช่วยเหลือครับ จะต้องเขียน code ที่ถูกต้องเพื่อที่จะ insert รายการของ cell1.innerHTML ไปฐานข้อมูลอย่างไรครับ



 

ขอความช่วยเหลือครับ จะต้องเขียน code ที่ถูกต้องเพื่อที่จะ insert รายการของ cell1.innerHTML ไปฐานข้อมูลอย่างไรครับ

 



Topic : 126079



โพสกระทู้ ( 111 )
บทความ ( 0 )



สถานะออฟไลน์




ต้องขอโทษที่ต้องยก Code มาทั้งหมด(ยาวหน่อยครับ)


repair_input.php


<Code (PHP)
!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" xml:lang="en-gb" lang="en-gb" >
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <script type="text/javascript" src="../jQueryui/jQuery.js"></script>
  <script type="text/javascript" src="../jQueryui/jQuery-ui.js"></script>

</head>    
    
<form action="insertData.php" method="post" name="adminForm" id="adminForm">
  <table class="adminlist">
    <thead>
      <tr>
        <th ><div class="titleleft"> เพิ่มรายการซ่อม </div>
          <div class="titleright"> <a href="#" onclick="document.adminForm.task.value=''; document.adminForm.submit();">
            <div id="icon">
              <div class="icon-32-cancel"></div>
              <div class="title">ยกเลิก</div>
            </div>
            </a> <a href="#" onclick="save();">
            <div id="icon">
              <div class="icons-32-save"></div>
              <div class="title">บันทึก</div>
            </div>
            </a> </div></th>
      </tr>
    </thead>
  </table>
  <fieldset class="adminform">
    <legend>ข้อมูลเบื้องต้น</legend>
  </fieldset>
  
  
  
  <fieldset class="adminform">
    <legend>รายละเอียดการซ่อม</legend>
    
  <table class="adminlist">
    <thead>
      <tr>
        <th width="90" >วันที่</th>
        <th width="61" >รหัส</th>
        <th width="87" >เลขใบเสร็จ</th>
        <th width="87" >รหัสอะไหล่</th>
        <th width="157">รายละเอียดการซ่อม</th>
        <th width="37" >จำนวน</th>
        <th width="47" >หน่วยละ</th>
        <th width="47" >ลด</th>
        <th width="47" >ยอดรวม</th>
        <th width="87" >ผู้ตรวจรับรถ</th>
        <th width="87" >สถานที่เข้าซ่อม</th>
        <th></th>
      </tr>
    </thead>
      <tbody id="repairlist">
      <tr>
     	 <td colspan="12">ยังไม่มีรายการใหม่ เพิ่มรายการใหม่ด้านล่าง</td>
      </tr>
      </tbody>
      <tr>
        <th width="90" >วันที่</th>
        <th width="61" >รหัส</th>
        <th width="87" >เลขใบเสร็จ</th>
        <th width="87" >รหัสอะไหล่</th>
        <th width="157">รายละเอียดการซ่อม</th>
        <th width="37" >จำนวน</th>
        <th width="47" >หน่วยละ</th>
        <th width="47" >ลด</th>
        <th width="47" >ยอดรวม</th>
        <th width="87" >ผู้ตรวจรับรถ</th>
        <th width="87" >สถานที่เข้าซ่อม</th>
        <th></th>
      </tr>
    <tr>
      <td><input type="text" name="date_repair" id="datepicker" value="" class="inputbox" size="25" maxlength="19" style="width:65px !important;" />
        <img src="../image/calendar.png" width="16" height="16" alt="logo" longdesc="calendar.png" /></td>
      <td><select name="rid" id="rid" style="width:60px !important;" class="inputbox" size="1"  ><option value="0"  selected="selected">R-ID</option><option value="7" >เครื่องยนต์</option><option value="8" >ห้องเครื่อง</option><option value="9" >ระบบแอร์</option><option value="10" >ระบบไฟฟ้า</option><option value="11" >เบรค-ยาง-ล้อ</option><option value="12" >ช่วงล่าง</option><option value="13" >เกียร์เ-ฟืองท้าย</option><option value="14" >ภายใน</option><option value="16" >อุปกรณ์</option><option value="17" >ความสะอาด</option><option value="18" >เช็คระยะ-ระบบ</option><option value="19" >เคลม Warranty</option><option value="20" >เคลมประกันทำสีรถ</option></select></td>
      <td><input class="text_area" type="text" name="repair_number" id="repair_number" size="32" maxlength="250" style="width:80px !important;"  /></td>
      <td><input class="text_area" type="text" name="part_number" id="part_number" size="32" maxlength="250" style="width:80px !important;"  /></td>
      <td><input class="text_area" type="text" name="repair_detail" id="repair_detail" size="32" maxlength="250" style="width:150px !important;"  /></td>
      <td><input class="text_area" type="text" name="amount" id="amount" size="32" maxlength="250" style="width:30px !important;"  /></td>
      <td><input class="text_area" type="text" name="price_perunit" id="price_perunit" size="32" maxlength="250" style="width:40px !important;"  /></td>
      <td><input class="text_area" type="text" name="price_discount" id="price_discount" size="32" maxlength="250" style="width:40px !important;" onchange="caldiscount();"  /></td>
      <td><input class="text_area" type="text" name="price_total" id="price_total" size="32" maxlength="250" style="width:40px !important;"  /></td>
      <td><input class="text_area" type="text" name="recive_by" id="recive_by" size="32" maxlength="250" style="width:80px !important;"  /></td>
      <td><input class="text_area" type="text" name="repair_at" id="repair_at" size="32" maxlength="250" style="width:80px !important;"  /></td>
      <td></td>
    </tr>
    <tr>
        <th >เลขไมล์</th>
     	 <td ><input class="text_area" type="text" name="mile" id="mile" size="32" maxlength="10"  style="width:50px !important;" /></td>
        <th >หมายเหตุ</th>
     	 <td colspan="6"><input class="text_area" type="text" name="repair_remark" id="repair_remark" size="32" maxlength="250"  style="width:450px !important;" /></td>
     	 <td colspan="3"><input name="" type="button" value="เพิ่มลงในรายการ" onclick="addlist();" /></td>
      </tr>
  </table>
    </fieldset>
  <fieldset class="adminform">
  <table width="100%" border="0" cellspacing="1" cellpadding="0">
  
</table>

  </fieldset>
  <input type="hidden" name="Itemid" value="35" />
  <input type="hidden" name="option" value="com_car" />
  <input type="hidden" name="task" value="" />
  <input type="hidden" name="step" value="1" />
<input type="hidden" name="c777fc3101862d44330268006e1e1480" value="1" />  <input type="hidden" name="view" value="repairadd" />
</form>
<script language="javascript">
var indexlist = 0;
function caldiscount(){
		var form = document.getElementById('adminForm');
		   var check = true;
          var value =form.price_discount.value; //get characters
		  var perc = false;
          //check that all characters are digits, ., -, or ""
          for(var i=0;i <value.length; ++i)
          {
               var new_key = value.charAt(i); //cycle through characters
               if(((new_key < "0") || (new_key > "9")) && 
                    !(new_key == ""))
               {
				   if(new_key != "%"){
                    check = false;
                    break;
				   }else{
					 perc = true;  
				   }
               }
          }
		if(!check){
			alert("ตัวเลขเท่านั้น เช่น 300 หรือ 10%");
			form.price_discount.value = "";
			form.price_discount.focus();
		//	price_perunit
		//	price_total
		}else{
			if(perc){
				value = value.substr(0,value.length-1);
				value = parseInt(value,10);
				value =  (parseInt(form.price_perunit.value,10)*parseInt(form.amount.value,10))*(value/100);
			}
				form.price_total.value = (parseInt(form.price_perunit.value,10)*parseInt(form.amount.value,10))-value;
		}
}
function addlist(){
		var form = document.getElementById('adminForm');
	if(form.rid.selectedIndex == 0){
		alert("เลือกรหัสการซ่อม");
	}else{
		var tr = document.getElementById('repairlist');
		
		var rcount = tr.rows.length;
		if(rcount == 1){
			tr.deleteRow(0);
		}
		
		
		rcount = tr.rows.length;
		var row = tr.insertRow(rcount);
		row.setAttribute("id","rows"+indexlist);
		var cell1 = row.insertCell(0);
		cell1.innerHTML = form.date_repair.value;
		var cell1 = row.insertCell(1);
		cell1.innerHTML =  form.rid[form.rid.selectedIndex].text;
		var cell1 = row.insertCell(2);
		cell1.innerHTML = form.repair_number.value;
		var cell1 = row.insertCell(3);
		cell1.innerHTML = form.part_number.value;
		var cell1 = row.insertCell(4);
		cell1.innerHTML = form.repair_detail.value;
		var cell1 = row.insertCell(5);
		cell1.innerHTML = form.amount.value;
		var cell1 = row.insertCell(6);
		cell1.innerHTML = form.price_perunit.value;
		var cell1 = row.insertCell(7);
		cell1.innerHTML = form.price_discount.value;
		var cell1 = row.insertCell(8);
		cell1.innerHTML = form.price_total.value;
		var cell1 = row.insertCell(9);
		cell1.innerHTML = form.recive_by.value;
		var cell1 = row.insertCell(10);
		cell1.innerHTML = form.repair_at.value;
		var cell1 = row.insertCell(11);
		
		innervalue = "";
		innervalue += '<input type="hidden" name="repairlist['+indexlist+'][date_repair]" value="'+form.date_repair.value+'" />';
		innervalue += '<input type="hidden" name="repairlist['+indexlist+'][rid]" value="'+form.rid[form.rid.selectedIndex].value+'" />';
		innervalue += '<input type="hidden" name="repairlist['+indexlist+'][repair_number]" value="'+form.repair_number.value+'" />';
		innervalue += '<input type="hidden" name="repairlist['+indexlist+'][part_number]" value="'+form.part_number.value+'" />';
		innervalue += '<input type="hidden" name="repairlist['+indexlist+'][repair_detail]" value="'+form.repair_detail.value+'" />';
		innervalue += '<input type="hidden" name="repairlist['+indexlist+'][amount]" value="'+form.amount.value+'" />';
		innervalue += '<input type="hidden" name="repairlist['+indexlist+'][price_perunit]" value="'+form.price_perunit.value+'" />';
		innervalue += '<input type="hidden" name="repairlist['+indexlist+'][price_discount]" value="'+form.price_discount.value+'" />';
		innervalue += '<input type="hidden" name="repairlist['+indexlist+'][price_total]" value="'+form.price_total.value+'" />';
		innervalue += '<input type="hidden" name="repairlist['+indexlist+'][recive_by]" value="'+form.recive_by.value+'" />';
		innervalue += '<input type="hidden" name="repairlist['+indexlist+'][repair_at]" value="'+form.repair_at.value+'" />';
		innervalue += '<input type="hidden" name="repairlist['+indexlist+'][repair_remark]" value="'+form.repair_remark.value+'" />';
		innervalue += '<input type="hidden" name="repairlist['+indexlist+'][mile]" value="'+form.mile.value+'" />';
		innervalue += '<input name="" type="button" value="ลบ" onclick="removeRows(\''+"rows"+indexlist+'\');" />';
		cell1.innerHTML = innervalue;
		cell1.setAttribute("rowSpan",2);
		
		rcount = tr.rows.length;
		row = tr.insertRow(rcount);
		cell1 = row.insertCell(0);
		cell1.innerHTML = "เลขไมล์";
		cell1 = row.insertCell(1);
		cell1.innerHTML = form.mile.value;
		cell1 = row.insertCell(2);
		cell1.innerHTML = "หมายเหตุ";
		cell1 = row.insertCell(3);
		cell1.innerHTML = form.repair_remark.value;
		cell1.setAttribute("colSpan",8);
		
		indexlist++;
		
		form.rid.selectedIndex=0;
		form.part_number.value="";
		form.repair_detail.value="";
		form.amount.value="";
		form.price_perunit.value="";
		form.price_discount.value="";
		form.price_total.value="";
		form.recive_by.value="";
		form.repair_at.value="";
		form.repair_remark.value="";
	}
}
function removeRows(rowid){
	var tr = document.getElementById('repairlist');
	for(var i=0;i<tr.rows.length;i++){
		if(tr.rows[i].id == rowid){
			tr.deleteRow(i);
			tr.deleteRow(i);
			break;
		}
	}

}
		function gencarlist(id){
			if(id.selectedIndex > 0){
			var selectid = id[id.selectedIndex].value;
			var carlist = new Array();
						var carlicense = document.getElementById('carlicense');
			
			var oplength = carlicense.options.length;
			
			while(oplength){
				oplength = carlicense.options.length;
				for(i=0;i<=oplength;i++){
					carlicense.options[i] = null;
				}
			}
			carlicense.options[0] = new Option('select car','0');
				for(i=1;i<=carlist[selectid].length;i+=2){
					carlicense.options[(i+1)/2] = new Option(carlist[selectid][i],carlist[selectid][i-1]);
				}
			}
		}
		function save(){
			document.adminForm.step.value='3'; 
			document.adminForm.submit();
		}
		</script>
</div>

</body>
<script type="text/javascript">
$(function(){
	 $("#datepicker").datepicker({ dateFormat: "yy-mm-dd" }).val('<? $date = date("Y-m-d");echo $date?>')
	 
});
</script></html> 
 <link href="../jQueryui/jQuery-ui.css" rel="stylesheet" type="text/css"/>


[/php]

insertData.php

Code (PHP)
 Code (PHP)
[php]<?php
  include('../config.php');
  
    if($_POST[save])
    {
     foreach ($_POST['rid'] as $key => $value) 
        {
            $rid = $_POST["rid"][$key];
            $date_repair = $_POST["date_repair"][$key];
            $repair_number = $_POST["repair_number"][$key];
             $repair_detail = $_POST["repair_detail"][$key];
			 $part_numbert = $_POST["part_number"][$key];
              $amount = $_POST["amount"][$key];
               $price_perunit = $_POST["price_perunit"][$key];
                $price_discount = $_POST["price_discount"][$key];
                 $price_total = $_POST["price_total"][$key];
                  $recive_by = $_POST["recive_by"][$key];
                   $repair_at = $_POST["repair_at"][$key];
                    $mile = $_POST["mile"][$key];
                    $repair_remark = $_POST["repair_remark"][$key];
  
            $strsql = mysql_query("insert into repair_table values
			 ('',
            '$rid', 
            '$date_repair',
            '$repair_number', 
            '$repair_detail', 
			'$part_number', 
            '$amount', 
            '$price_perunit', 
            '$price_discount', 
            '$price_total', 
            '$recive_by', 
            '$repair_at', 
            '$mile',  
            '$repair_remark')");        
		
       mysql_query($strsql);
if($strsql){
	   exit ("<script> window.location='repair_input.php';</script>");

}
	}
		}
         ?>
   
    


[/php]



Tag : PHP









ประวัติการแก้ไข
2017-01-18 10:16:55
2017-01-18 10:18:12
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2017-01-18 10:12:43 By : panya@ots View : 561 Reply : 2
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ถ้าลง HTML Element จะต้องอ่านค่ามันลง Form Element ก่อนที่จะ Submit ส่งไปครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-01-18 15:59:00 By : mr.win
 


 

No. 2



โพสกระทู้ ( 111 )
บทความ ( 0 )



สถานะออฟไลน์


รบกวนขอตัวอย่างหน่อยซิครับ ขอบพระคุณมากครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-01-18 17:49:15 By : panya@ots
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ขอความช่วยเหลือครับ จะต้องเขียน code ที่ถูกต้องเพื่อที่จะ insert รายการของ cell1.innerHTML ไปฐานข้อมูลอย่างไรครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่