|
 |
|
มีเรื่องรบกวนอีกแล้ว ช่วยเข้ามาอ่านที่ครับ ขอบคุณล่วงงหน้าครับผม |
|
 |
|
|
 |
 |
|
รายละเอียดส่วนของฟอร์ม รับข้อมูลคับ
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GG-->GUNdum</title>
<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>
<title>GG>>GUNdum</title>
</head>
<body>
<p align="center"><em><strong>ใส่ข้อมูลการเสนอราคา</strong></em>
<?
$objConnect = mysql_connect("localhost","root","1111") or die("Error Connect to Database");
$objDB = mysql_select_db("newproject");
?>
</p>
<form action="test3.php" name="frmAdd" method="post"><div align="center">
เพิ่มรายการ :
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
</div>
<?
for($i=1;$i<=10;$i++)
{
if($_GET["Line"] == $i)
{
$sel = "selected";
}
else
{
$sel = "";
}
?>
<option value="<?=$_SERVER["PHP_SELF"];?>?Line=<?=$i;?>" <?=$sel;?>><?=$i;?></option>
<?
}
?>
</select>
<table width="473" height="62" border="1" align="center">
<tr>
<th width="171" height="26">รายการสินค้า</th>
<th width="150"> <div align="center">รายชื่อบริษัท</div></th>
<th width="130">เสนอราคา</th>
</tr>
<?
$line = $_GET["Line"];
if($line == 0){$line=1;}
for($i=1;$i<=$line;$i++)
{
?>
<tr>
<td height="27"><label> </label>
<div align="center">
<?
$strSQL = "SELECT id_product,Nproduct FROM product";
$objQuery = mysql_query($strSQL);
?>
<select name="id_product" id="id_product" style="width:150 px" id_product="select<?=$i;?>">
<option value="">::เลือกรายการ::</option>
<?
while(list($id_product,$Nproduct) = mysql_fetch_row($objQuery))
{
echo "<option value=$id_product<?=$i;?> $Nproduct <?=$i;?> </option>" ;
}
?>
</select>
</div></td>
<td><div align="center">
<?
$strSQL = "SELECT id_company,Ncompany FROM company ";
$objQuery = mysql_query($strSQL);
?>
<select name="id_company" id="id_company" style="width:100 px" id_company="select<?=$i;?>">
<option value="">::เลือกรายการ::</option>
<?
while(list($id_company,$Ncompany) = mysql_fetch_row($objQuery))
{
echo "<option value=$id_company<?=$i;?> $Ncompany<?=$i;?> </option>" ;
}
?>
</select>
</div></td>
<td><label>
<input name="price" type="text" id="price" size="20" maxlength="10">
</label>
</td>
<?
}
?>
</tr>
</table><br><br>
<input type="submit" name="submit" value="submit"></div>
<input type="hidden" name="hdnLine" value="<?=$i;?>"></div>
</form>
<?
mysql_close($objConnect);
?>
</body>
</html>[/head]
วันนี้มีเรื่องรบกวนอีกแล้วครับ
คือว่าผมได้ทำการดึง รายชื่อ ของสินค้า และ บริษัท มาจาก 2 ตาราง คือ ตาราง producr และตาราง company
เพื่อที่จะทำการเปรียบเทียบราคาของสินค้าแต่ละตัว แล้วทีนี้เวลาผม จะเก็บขอมูลของตารางที่ 3 ตาราง pro_comp
ซึ่งในหน้ารับข้อมูล ผมให้แสดงรายการ ต่างๆเป็น text แล้วถ้าผมจะบันทึกข้อมูลลง เบส โดยให้เก็บ เป็น PK ของ 2 ตารางแรก
พอจะมีแนวทางไหมครับ 

ตารางที่เกี่ยวข้องคือ
table product
table company
และ table pro_comp
Tag : PHP, MySQL

|
ประวัติการแก้ไข 2012-04-24 13:32:51 2012-04-24 13:33:36 2012-04-24 13:34:58
|
 |
 |
 |
 |
Date :
2012-04-24 10:25:35 |
By :
GUNdum |
View :
938 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยดันหน่อยคับ 
|
 |
 |
 |
 |
Date :
2012-04-24 13:31:07 |
By :
GUNdum |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เท่าที่ดู คุณมีข้อมูลหมดแล้วนี่ครับ ขาดแค่ตอน insert ใช่ไหม
คุณลอง echo ค่าตัวแปรออกมาดูในหน้า insert ก่อนครับ
แล้วค่อยเขียนคำสั่ง SQL insert
|
 |
 |
 |
 |
Date :
2012-04-24 13:59:07 |
By :
rootElement@kmutnb |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|