|
|
|
ใช้คำสั่ง while กับ mysql_fetch_array แต่กลับได้ค่าเป็น array1,array2,array3,arrayN... เป็นเพราะอะไรครับ |
|
|
|
|
|
|
|
คือผมต้องการใช้รันแรก โดยบวกตัวแปร มันทำไมมันเข้า db แบบนี้ละครับช่วยดูให้หน่อยครับ แฮๆ
Code (PHP)
<?require_once("session.php")?>
<?
include ("header_main.php");
?>
<script type="text/javascript" language="javascript" src="datetimepicker.js"></script>
<script language="JavaScript">
<!--
if (document.images)
{
calimg= new Image(16,16);
calimg.src="image/cal.gif";
}
function test123()
{
alert("onchange event triggered.");
}
//-->
</script>
<?
$query=mysql_query("select * from request where cus_ord_id = '$search'");
$i = 1;
while ($rs1=mysql_fetch_array ($query)) {
// $var_p_code[$i]=$rs1["pro_id"];
// $var_p_qty[$i]=$rs1["qty"];
$var_p_price[$i]=$rs1["price"];
}
$i++;
?>
<form name ="form_issue" method="post" action="product_sales_add.php" >
<table cellpadding=0 cellspacing=0 border=0 height="200" align='center' >
<tr>
<td height=1 colspan=15 bgcolor=#9DBEE6><img src="image/dot.gif"></td>
</tr>
<tr>
<td height=20 width=1 bgcolor=#9DBEE6 ></td>
<td height=20 colspan="3" bgcolor=#ffffff >
<div align="center"><font face="MS Sans Serif, Microsoft Sans Serif" color="#6C7198" size="4"><b>บันทึกเบิกสินค้าสำหรับขาย</b></font>
</div>
</td>
<td height=20 width=1 bgcolor=9DBEE6></td>
</tr>
<tr>
<td height=1 colspan=15 bgcolor=#9DBEE6><img src="image/dot.gif"></td>
</tr>
<tr>
<td height=20 width=1 bgcolor=#9DBEE6 ></td>
<td height=20 width=123 bgcolor=ffffff >
<div align="right"><b><font face="MS Sans Serif, Microsoft Sans Serif" color="#6C7198" size="2">ใบเสนอราคาเลขที่ </font></b></div>
</td>
<td height=20 width=1 bgcolor=9DBEE6 ><font face="MS Sans Serif, Microsoft Sans Serif" color="#CCCCCC" size="2"></font></td>
<td height=20 width=388 bgcolor=ffffff valign="middle" ><font face="MS Sans Serif, Microsoft Sans Serif" color="#6C7198" size="2">
<? echo "<input type='hidden' name='i_q_no' value='$search'>"; echo $search; ?>
<input type="hidden" name="i_type" value="SOLD">
<?
$today = getdate();
$toyear = $today["year"] + 543 ;
$var_i_date = $today["mday"]."/".$today["mon"]."/".$toyear;
echo "<input type='hidden' name='i_date' size='25' maxlength='25' value='$var_i_date'>";
?>
</font></td>
<td height=20 width=1 bgcolor=9DBEE6></td>
</tr>
<!--------------------------------------------------------------------------------------->
<?$query=mysql_query("select * from request where cus_ord_id = '$search'");
$i=1;
while ($rs1=mysql_fetch_array ($query)) {
?>
<tr>
<td height=1 colspan=15 bgcolor=#9DBEE6><img src="image/dot.gif"></td>
</tr>
<tr>
<td height=20 width=1 bgcolor=#9DBEE6 ></td>
<td height=20 width=123 bgcolor=ffffff >
<div align="right"><b><font face="MS Sans Serif, Microsoft Sans Serif" size="2" color="#6C7198">ลำดับที่ <?=$i?> </font></b></div>
</td>
<td height=20 width=1 bgcolor=9DBEE6 ><font face="MS Sans Serif, Microsoft Sans Serif" color="#CCCCCC" size="2"></font></td>
<td height=20 width=450 bgcolor=ffffff valign="middle" ><font face="MS Sans Serif, Microsoft Sans Serif" color="#6C7198" size="2">
<?
echo " <b>สินค้า:</b> ".$rs1["pro_name"];
echo " จำนวน: ".$rs1["qty"];
echo " ชุด";
?>
</font></td>
<td height=20 width=1 bgcolor=9DBEE6></td>
</tr>
<? $i++;
}
?>
<!----------------------------------------------------------------------------------------------------------------------------------->
<?
$result = mysql_query("select * from request where cus_ord_id = '$search'", $Conn);
$num_rows = mysql_num_rows($result);
for($j=1;$j<=$num_rows;$j++) {
?>
<td height=20 width=1 bgcolor=9DBEE6></td>
</tr>
<tr>
<td height=1 colspan=15 bgcolor=#9DBEE6><img src="image/dot.gif"></td>
</tr>
<tr>
<td height=20 width=1 bgcolor=#9DBEE6 ></td>
<td height=20 width=123 bgcolor=ffffff >
<div align="right"><b><font face="MS Sans Serif, Microsoft Sans Serif" size="2" color="#6C7198">เบิกสินค้าลำดับที่ <?=$j?> </font></b></div>
</td>
<td height=20 width=1 bgcolor=9DBEE6 ><font face="MS Sans Serif, Microsoft Sans Serif" color="#CCCCCC" size="2"></font></td>
<td height=20 width=450 bgcolor=ffffff valign="middle" ><font face="MS Sans Serif, Microsoft Sans Serif" color="#6C7198" size="2">
<?
echo " <b>สินค้า:</b> ";
echo "<select name='i_p_code".$j."' size='1' value ='' >
<option value=''>กรุณาเลือกสินค้า</option> ";
$query=mysql_query("select pro_id ,pro_name from product");
while ($rs1=mysql_fetch_array ($query)) {
$var_p_code[$j]=$rs1['pro_id'];
$var_p_name[$j]=$rs1['pro_name'];
echo "<option value='$var_p_code".$j."'>$var_p_code[$j] - $var_p_name[$j]</option>";
}
echo "</select>";
echo "<input type='hidden' name='i_p_qty[$j]' size='11' maxlength='11' value='1'>";
echo "<input type='hidden' name='var_p_price[$j]' size='11' maxlength='11' value='1'>";
echo " รหัสสินค้า: ";
echo "<select name='i_p_sn".$j."' size='1' value ='' >
<option value=''>กรุณาเลือกรหัสสินค้า</option> ";
$query=mysql_query("select r_p_sn,r_p_id from recive ,product where product.pro_id = '$var_p_code[$j]' and recive.r_type='SOLD'");
while ($rs1=mysql_fetch_array ($query)) {
$var_p_sn[$j]=$rs1['r_p_sn'];
$var_p_id[$j]=$rs1['r_p_id'];
echo "<option value='$var_p_sn[$j]'>$var_p_id[$j] : $var_p_sn[$j]</option>";
}
echo "</select>";
?>
</font></td>
<!---------------------------------------------------------------------------->
<?
}
?>
<td height=20 width=1 bgcolor=9DBEE6></td>
</tr>
<tr>
<td height=1 colspan=15 bgcolor=#9DBEE6><img src="image/dot.gif"></td>
</tr>
<tr>
<td height=20 width=1 bgcolor=#9DBEE6 ></td>
<td height=20 width=123 bgcolor=ffffff >
<div align="right"><b><font face="MS Sans Serif, Microsoft Sans Serif" color="#6C7198" size="2">วันที่เริ่มประกัน </font></b></div>
</td>
<td height=20 width=1 bgcolor=9DBEE6 ><font face="MS Sans Serif, Microsoft Sans Serif" color="#CCCCCC" size="2"></font></td>
<td height=20 width=388 bgcolor=ffffff valign="middle" ><font face="MS Sans Serif, Microsoft Sans Serif" color="#CCCCCC" size="2">
<input name = "dates" id="date2" type="text" size="15"><a href="javascript:NewCal('date2','ddmmyyyy')"><img src="image/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
</font></td>
<td height=20 width=1 bgcolor=9DBEE6></td>
</tr>
<tr>
<td height=1 colspan=15 bgcolor=#9DBEE6><img src="image/dot.gif"></td>
</tr>
<tr>
<td height=20 width=1 bgcolor=#9DBEE6 ></td>
<td height=20 width=123 bgcolor=ffffff >
<div align="right"><b><font face="MS Sans Serif, Microsoft Sans Serif" color="#6C7198" size="2">ถึงวันที่ </font></b></div>
</td>
<td height=20 width=1 bgcolor=9DBEE6 ><font face="MS Sans Serif, Microsoft Sans Serif" color="#CCCCCC" size="2"></font></td>
<td height=20 width=388 bgcolor=ffffff valign="middle" ><font face="MS Sans Serif, Microsoft Sans Serif" color="#CCCCCC" size="2">
<input name ="datef" id="date3" type="text" size="15"><a href="javascript:NewCal('date3','ddmmyyyy')"><img src="image/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
</font></td>
<td height=20 width=1 bgcolor=9DBEE6></td>
</tr>
<tr>
<td height=1 colspan=15 bgcolor=#9DBEE6><img src="image/dot.gif"></td>
</tr>
<tr>
<td height=20 width=1 bgcolor=#9DBEE6 ></td>
<td height=20 width=123 bgcolor=ffffff >
<div align="right"><b><font face="MS Sans Serif, Microsoft Sans Serif" color="#6C7198" size="2"> </font></b></div>
</td>
<td height=20 width=1 bgcolor=9DBEE6 ><font face="MS Sans Serif, Microsoft Sans Serif" color="#CCCCCC" size="2"></font></td>
<td height=20 width=388 bgcolor=ffffff valign="middle" ><font face="MS Sans Serif, Microsoft Sans Serif" color="#CCCCCC" size="2">
<input type="submit" name="Submit" value="บันทึก">
<input type="reset" name="Reset" value="ยกเลิก" onClick="window.close(); "></font></td>
<td height=20 width=1 bgcolor=9DBEE6></td>
</tr>
<tr>
<td height=1 colspan=15 bgcolor=#9DBEE6><img src="image/dot.gif"></td>
</tr>
</table>
</form>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2011-08-31 23:15:57 |
By :
bukla |
View :
906 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เปลี่ยนการเขียน ตัวแปร / Loop ใหม่ครับ แบบนี้ Debug ลำบากครับ
Code (PHP)
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="59"> <div align="center">Budget </div></th>
<th width="71"> <div align="center">Used </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?=$objResult["CustomerID"];?></div></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Email"];?></td>
<td><div align="center"><?=$objResult["CountryCode"];?></div></td>
<td align="right"><?=$objResult["Budget"];?></td>
<td align="right"><?=$objResult["Used"];?></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
Go to : PHP MySQL List Record
|
|
|
|
|
Date :
2011-09-01 06:37:17 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ครับ ขอบคุณมากครับพี่ ผมจะขอไปปรับปรุงโปรแกรมตัวเองก่้อนครับ
|
|
|
|
|
Date :
2011-09-02 11:06:35 |
By :
bukla |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|