|
|
|
พี่ๆคับขอควมกรุณาครับ เรื่อง PHP MySQL Add/Insert Multiple Record คับผม |
|
|
|
|
|
|
|
คืออย่างนี้คับ ผมอยากทำการ Add/Insert Multiple Record โดยเลือกแถวมาก่อน ว่าต้องการกี่แถว แล้วแต่ละแถวก้อมีไห้เลือก list menu สองชั้น ผมทำแล้วทำไมมันเลือกไม่ได้ อะคับ ผมไม่รุทำไงดี
ปล ต้องขอโทดด้วยคับ รูปมันอัพไม่ขึ้น
Code (PHP)
<? session_start();
include "db.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>Carphongpat</title>
<script language = "JavaScript">
//**** List Province (Start) ***//
function ListProvince(SelectValue)
{
frmMain.ddlProvince.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('---กรุณาเลือก---','')
frmMain.ddlProvince.options[frmMain.ddlProvince.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM product_part ORDER BY Pro_Part_ID ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = <?=$objResult["Pro_Part_Type_ID"];?>;
strValue = "<?=$objResult["Pro_Part_ID"];?>";
strItem = "<?=$objResult["Pro_Part_Name"];?>";
mySubList[x,0] = strItem;
mySubList[x,1] = strGroup;
mySubList[x,2] = strValue;
if (mySubList[x,1] == SelectValue){
var myOption = new Option(mySubList[x,0], mySubList[x,2])
frmMain.ddlProvince.options[frmMain.ddlProvince.length]= myOption
}
<?
}
?>
}
//**** List Province (End) ***//
//**** List Amphur (Start) ***//
//**** List Amphur (End) ***//
</script>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<style type="text/css">
<!--
@import url("../css/styless.css");
-->
</style>
<body>
<?
$Oder_ID=$_GET['Oder_ID'];
$sql_emp=mysql_query("SELECT * FROM oder WHERE Oder_ID='$Oder_ID'");
$re_emp=mysql_fetch_assoc($sql_emp);
?>
<form name="frmMain" action="oder_save.php" method="post" onsubmit="return chkData(this);">
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<?
for($i=1;$i<=50;$i++)
{
if($_GET["Line"] == $i)
{
$sel = "selected";
}
else
{
$sel = "";
}
?>
<option value="<?=$_SERVER["PHP_SELF"];?>?Line=<?=$i;?>" <?=$sel;?>><?=$i;?></option>
<?
}
?>
</select>
<input type="hidden" name="Oder_ID" value="<?=$re_emp['Oder_ID']; ?>">
<input name="OderID" type="hidden" id="Oder_ID" value="<?=$re_emp['Oder_ID']; ?>">
<?
$sqldepartment = "SELECT Pro_Part_ID,Pro_Part_Name FROM product_part Order by Pro_Part_Name asc";
$resdepartment = mysql_query($sqldepartment);
$datadepartment1 = mysql_fetch_array($resdepartment);
$p = "SELECT * FROM product_part WHERE Pro_Part_ID='".$re_emp["Pro_Part_ID"]." '";
$pp = mysql_query($p);
$ppp = mysql_fetch_array($pp);
$strJoin7="SELECT product_part_type.*, product_part.* FROM product_part_type, product_part WHERE product_part_type.Pro_Part_Type_ID = product_part.Pro_Part_Type_ID AND product_part.Pro_Part_Type_ID = '".$ppp["Pro_Part_Type_ID"]."'";
$objQuery18 = mysql_query($strJoin7) or die ("Error Query [".$strJoin7."]");
$objResult18 = mysql_fetch_array($objQuery18);
//echo $objResult18["Pro_Part_Type_Name"];
?>
<table a align="center" width="338" border="1" id="ver-zebra" summary="Most Favorite Movies">
<tr>
<th colspan="4" align="center"><strong>แก้ไขข้อมูลรายการอะไหล่</strong></th>
</tr>
<?
$line = $_GET["Line"];
if($line == 0){$line=1;}
for($i=1;$i<=$line;$i++)
{
?>
<tr>
<td><div align="left"><strong>ประเภท:</strong></div></td>
<td><select id="ddlGeo" name="ddlGeo" onChange = "ListProvince(this.value)">
<option selected value="">---กรุณาเลือก---</option>
<?
$strSQL = "SELECT * FROM product_part_type ORDER BY Pro_Part_Type_ID ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mysql_fetch_array($objQuery))
{
?>
<option value="<? echo $objResult[Pro_Part_Type_ID]?>" <? if($objResult[Pro_Part_Type_ID] ==$ppp[Pro_Part_Type_ID]){ echo 'selected=selected';}?>><? echo $objResult[Pro_Part_Type_Name];?></option>
<?
}
?>
</select>
<select name="Pro_Part_ID" id="ddlProvince">
<?
while($datadepartment = mysql_fetch_array($resdepartment)){
?>
<option value="<? echo $datadepartment[Pro_Part_ID]?>" <? if($datadepartment[Pro_Part_ID] ==$re_emp[Pro_Part_ID]){ echo 'selected=selected';}?>><? echo $datadepartment[Pro_Part_Name];?></option>
<? }?>
</select></td>
</tr>
<?
}
?>
<tr>
<th colspan="4" align="center">
<input type="submit" name="save" id="save" value="อัพเดท" onclick="window.opener.location.reload();" />
<input type="reset" name="cancle" id="cancle" value="ยกเลิก" onclick="window.close();" />
</th>
</tr>
</table>
</form>
</body>
</html>
Tag : PHP, HTML/CSS, JavaScript
|
|
|
|
|
|
Date :
2013-08-03 21:39:20 |
By :
บ้านนอกคับป๋ม |
View :
661 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|