|
 |
|
อยากทราบว่าโค๊ดเขียนยังไงหรอครับ คือต้องเขียนให้มันแสดง text box ตามจำนวนที่ต้องการใน list box ครับ |
|
 |
|
|
 |
 |
|
น่าจะเหมือนตัวนี้ครับ
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
for($i=1;$i<=$_POST["hdnLine"];$i++)
{
if($_POST["txtCustomerID$i"] != "")
{
$strSQL = "INSERT INTO customer ";
$strSQL .="(CustomerID,Name,Email,CountryCode,Budget,Used) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtCustomerID$i"]."','".$_POST["txtName$i"]."', ";
$strSQL .="'".$_POST["txtEmail$i"]."' ";
$strSQL .=",'".$_POST["txtCountryCode$i"]."','".$_POST["txtBudget$i"]."', ";
$strSQL .="'".$_POST["txtUsed$i"]."') ";
$objQuery = mysql_query($strSQL);
}
}
echo "Save Done. Click <a href='phpMySQLListRecord.php'>here</a> to view.";
mysql_close($objConnect);
?>
</body>
</html>
Go to : PHP MySQL Add/Insert Multiple Record
|
 |
 |
 |
 |
Date :
2011-08-15 06:40:54 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
form.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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#nummail').change(function(){
$.get(
'mail_input.php',
{numinput:$('#nummail').val()},
function(data){
$('#emailtotal').html(data);
},
'html'
);
});
});
</script>
</head>
<body>
<p> จำนวนอีเมลล์ที่ต้องการกรอก <select id="nummail">
<option value'' />-</option>
<?php
for($i=1;$i<=5;$i++) {
echo "<option value='".$i."' />".$i."</option>\n";
}
?>
</select>
</p>
<div id="emailtotal"></div>
</body>
</html>
mail_input.php
<?php
$numinput = isset($_GET['numinput']) ? $_GET['numinput'] : '';
for($i=1;$i<=$numinput;$i++) {
echo "อีเมลล์ที่ ".$i." : <input type='text' name='email[]' size='20' /><br />\n";
}
?>
ปล. ส่งค่าเป็น array $eamil ไปน่ะครับ
|
ประวัติการแก้ไข 2011-08-15 06:55:19
 |
 |
 |
 |
Date :
2011-08-15 06:49:20 |
By :
tomrambo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณทุกท่านมากครับ
|
 |
 |
 |
 |
Date :
2011-08-15 10:39:53 |
By :
l3luewater |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|