<!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>
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>
$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])"; ... }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง