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 รับค่าจากข้อมูลนี้เข้า databaseให้ทีครับ ติดมาหลายวันแล้วครับ



 

ช่วยเขียน code รับค่าจากข้อมูลนี้เข้า databaseให้ทีครับ ติดมาหลายวันแล้วครับ

 



Topic : 120997



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



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




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">
<script>
		var counter = 1;
		var limit = 10;
		function addInput(divName){
   		  if (counter == limit)  {
      		    alert("You have reached the limit of adding " + counter + " inputs");
   		  }
     		else {
        		  var newdiv = document.createElement('div');
        		  newdiv.innerHTML = "Entry " + (counter + 1)  + "<input type='text' name='myInputs[]'>";
        		  document.getElementById(divName).appendChild(newdiv);
        		  counter++;
   		  }
		}
		</script>
        
        
         <script>
		var counter2 = 1;
		var limit2 = 6;
		function addInput2(divName){
   		  if (counter2 == limit2)  {
      		    alert("You have reached the limit of adding " + counter2 + " inputs");
   		  }
     		else {
				// Find a <table> element with id="myTable":
				var table = document.getElementById("po");

				// Create an empty <tr> element and add it to the 1st position of the table:
				var row = table.insertRow(-1);

				// Insert new cells (<td> elements) at the 1st and 2nd position of the "new" <tr> element:
				var cell1 = row.insertCell(0);
				var cell2 = row.insertCell(1);
				var cell3 = row.insertCell(2)
				var cell4 = row.insertCell(3)
				var cell5 = row.insertCell(4)
				// Add some text to the new cells:
				cell1.innerHTML = "<input type='text' name='Product_name[]'>";
				cell2.innerHTML = "<input type='text' name='Size[]'>";
				cell3.innerHTML = "<input type='text' name='Quantity[]'>";
				cell4.innerHTML = "<input type='text' name='Price[]'>";
				cell5.innerHTML = "<input type='text' name='Amount[]'>";
				counter2++;		
   		  }
		}
		</script>

<head>
<?php
	mysql_connect("localhost","root","abcd1234") or die(mysql_error());
	mysql_query("SET NAMES UTF8");
	mysql_select_db("thaimee");
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form Add PO</title>
<style type="text/css">
#con {
	text-align: center;
}
#con {
	text-align: left;
}
#con {
	text-align: left;
}
#con {
	text-align: left;
}
</style>

 <link rel="stylesheet" href="css/style.css">
</head>

<body>
<h1>Add Po</h1>
<fieldset>
    <legend>PO</legend>
    <form action="show_po.php" method="post" />
<table>
<tr>
<td>Contact person</td><td><input type="text" name="Contact_Person" /><br /></td>
</tr>
<tr>

</tr>
<tr>
<td>Date</td>
<td><?
 
    $date = date("Y-m-d");
    
     
    echo $date."  ".$time;
 
?>  </td>
</tr>
<tr>
<td>Company Number:</td><td><input type="text" name="Company_Number" /><br /></td>
</tr>
<tr>
<td>Po Number</td><td><input type="text" name="Po_number" /><br /></td>


</tr>

<tr>

<tr>
<td>Fax</td><td><input type="text" name="Company_Fax" /><br /></td>
</tr>


<tr>
<td>
<?
	$objConnect = mysql_connect("localhost","root","abcd1234") or die("Error Connect to Database");
	mysql_query("SET NAMES UTF8");
	$objDB = mysql_select_db("thaimee");
	
	$query = mysql_query("select company from po;"); // Run your query

	echo ' Company: <select name="company">'; // Open your drop down box

	// Loop through the query results, outputing the options one by one
	while ($row = mysql_fetch_array($query)) {
   	echo '<option value="'.$row['company'].'">'.$row['company'].'</option>';
}

echo '</select>';// Close your drop down box
?>
</td>
<td>

</tr>


</table> 
  <table width="150" border="0">
  <tr>
  
    <td><input type="submit" value="Submit" ></form></td>
   
  </tr>
</table>




        
        <!-- For po -->
        <table id="po">
    	<tr>    
        <td>Product</td>
        <td>Size</td>
        <td>Quantity</td>
        <td>Unit Price</td>
        <td>Amount</td>
        <td>
    	</tr>
    
    	<tr>
        <td><input type="text" name="Product_name[]" ></td>
        <td><input type="text" name="Size[]"></td>
        <td><input type="text" name="Quantity[]"></td>
        <td><input type="text" name="Price[]"></td>
        <td><input type="text" name="Amount[]"></td>
    	</tr>
		</table>

		<tr>
    	<td><input type="button" value="Add " onClick="addInput2('packingtable');"></td>
    	</tr>
 





</body>
</html>



หน้าฟอร์ม



Tag : PHP, JavaScript









ประวัติการแก้ไข
2016-01-21 14:08:55
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2016-01-21 13:34:47 By : athiwatbuun View : 827 Reply : 2
 

 

No. 1



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

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

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

Quote:
<tr>
<td><input type="text" name="Product_name[]" ></td>
<td><input type="text" name="Size[]"></td>
<td><input type="text" name="Quantity[]"></td>
<td><input type="text" name="Price[]"></td>
<td><input type="text" name="Amount[]"></td>
</tr>


ใช้แบบ Array ไม่ได้ครับ ลองดูบทความนี้ครับ



JavaScript createElement Select and Get item from MySql Database







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-01-21 14:24:27 By : mr.win
 


 

No. 2

Guest


ลองไปปรับๆดู

Code
$count = count($_POST['Product_name']); for ($i = 0; $i < $count; $i++) { $sql = "INSERT INTO table VALUES($_POST['Product_name'][$i]_POST['size'][$i],$_POST['Quantity'][$i],$_POST['price'][$i],$_POST['Amount'][$i])"; ... }

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-01-21 23:05:22 By : noMerzy
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยเขียน code รับค่าจากข้อมูลนี้เข้า databaseให้ทีครับ ติดมาหลายวันแล้วครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 04
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 อัตราราคา คลิกที่นี่