基本上,我有2个表,它们是RequestOrder和OrderItem。 RequestOrder中有3个变量,分别是Category,Location和OrderType,OrderItem表中有1个变量。如何在此函数中放置另一个查询和结果以从 function OrderDetails($Role,$UserID,$Xexv){
$_SESSION['views']=true;
$RequestID = strtoupper(trim($_REQUEST['RequestID']));
global $DbHost;
global $DbUser;
global $DbPass;
global $DbName;
// Database connection
$link = mysql_connect($DbHost, $DbUser, $DbPass) or die('Could not connect: ' . mysql_error());
mysql_select_db($DbName) or die('Could not select database');
$query="select * from requestorder where RequestID='$RequestID'";
$result2 = mysql_query($query) or die('Query failed: ' . mysql_error());
$CategoryArray=array('Jig','Contactor');
$LocationArray=array('MUAR','AMK','TPY','STS','GOBM');
$OrderTypeArray=array('New/Prototype','Duplicate');
$CCPArray=array('-Select-','Yes','No');
if (mysql_num_rows($result2) == 0) {
displayMsg("NoData","");
exit;
}
$query="select RequestID,Category,TypeofOrder,Package,Device,Quantity,Location,CC,Requester,Date,Description,Status,LastUpdate,EmailList from requestorder where RequestID='$RequestID'";
$result=mysql_query($query) or die('Query failed: ' . mysql_error());
$row = mysql_fetch_row($result);
$RequestID=$row[0];
$RequestID="000"."$RequestID";
$Category=$row[1];
$TypeofOrder=$row[2];
$Package=$row[3];
$Device=$row[4];
$Quantity=$row[5];
$Location=$row[6];
$CC=$row[7];
$Requester=$row[8];
$Date=$row[9];
$Description=$row[10];
$Status=$row[11];
$LastUpdate=$row[12];
$EmailList=$row[13];
echo <<<EOT
<center><b>Order Details</b></center>
<center>
<form id="container" name="search" onsubmit="return isReadyIn(this);" action="hos.php" method="post" enctype="multipart/form-data">
<table class="tool">
<tr>
<td align="center" colspan=2 ><b>Request Infomation</b></td>
</tr>
<tr>
<td class="title">Request Date : </td><td>$Date</td>
</tr>
<tr>
<td class="title">Last Update : </td><td>$LastUpdate</td>
</tr>
<tr>
<td class="title">Request ID : </td><td>$RequestID</td>
</tr>
<tr>
<td class="title">Request Status : </td><td>$Status</td>
</tr>
<tr>
<td class="title">Requester : </td><td>$Requester</td>
</tr>
<tr>
<td class="title">Category : </td>
<td><select class="entry" name="Category">
EOT;
foreach ($CategoryArray as $key => $value)
{
if($value==$Category){
echo '<OPTION value='.$value.' selected> '.$value.'';
}
else{
echo '<OPTION value='.$value.'> '.$value.'';
}
}
echo <<<EOT
</select>
</td>
</tr>
<tr>
<td class="title">Type of Order : </td>
<td><select class="entry" name="TypeofOrder">
EOT;
foreach ($OrderTypeArray as $key => $value)
{
if($value==$TypeofOrder){
echo '<OPTION value='.$value.' selected> '.$value.'';
}
else{
echo '<OPTION value='.$value.'> '.$value.'';
}
}
echo <<<EOT
</select>
</td>
</tr>
<tr>
<td class="title">Package : </td><td><input type="text" name="Package" id="Package" value=$Package></td>
</tr>
<tr>
<td class="title">Device : </td><td><input type="text" name="Device" id="Device" maxlength="6" value=$Device></td>
</tr>
<tr>
<td class="title">Quantity : </td><td><input type="text" name="Quantity" id="Quantity" value=$Quantity></td>
</tr>
<tr>
<td class="title">Location : </td><td><select class="entry" name="Location">
EOT;
foreach ($LocationArray as $key => $value)
{
if($value==$Location){
echo '<OPTION value='.$value.' selected> '.$value.'';
}
else{
echo '<OPTION value='.$value.'> '.$value.'';
}
}
echo <<<EOT
</select></td>
</tr>
<tr>
<td class="title">Cost Center : </td><td><input type="text" name="CC" id="CC" value=$CC></td>
</tr>
<tr>
<td class="title">Email Group : </td><td><input type="text" name="EmailList" id="EmailList" value=$EmailList></td>
</tr>
<tr>
<td class="title"></td><td><b><p style="font-size:10px;">separate email address by semicolon symbol</td>
</tr>
<tr>
<td class="title">Description : </td><td><textarea class="entry" name="Description" id="Description">$Description</textarea></td>
</tr>
</table>
<div id="repeatingSection1">
EOT;
$query="select ItemID,OrderID,Supplier,WBS,PUC,Total,PR,CCP,PR_Date,PO,PO_Date,ExpectedDelivery,Shipment_Date,Remarks,AssetNumber,Quotation_Date,name_of_uploaded_Quotation,name_of_uploaded_PR,name_of_uploaded_PO from orderitem where RequestID='$RequestID'";
$result=mysql_query($query) or die('Query failed: ' . mysql_error());
$ItemCount=mysql_num_rows($result);
$ItemCounter=1;
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
if($ItemCounter==1){$Label="Main Item";}
else{
$divID="repeatingSection". $ItemCounter;
echo <<<EOT
<div id="$divID">
EOT;
$Label="Sub Item" . $ItemCounter;
}
$Supplier =$row['Supplier'];
$WBS =$row['WBS'];
$PUC =$row['PUC'];
$Total =$row['Total'];
$PR =$row['PR'];
$CCP =$row['CCP'];
$PR_Date =$row['PR_Date'];
$PO =$row['PO'];
$PO_Date =$row['PO_Date'];
$ExpectedDelivery =$row['ExpectedDelivery'];
$Shipment_Date= $row['Shipment_Date'];
$Remarks =$row['Remarks'];
$AssetNumber =$row['AssetNumber'];
$Quotation_Date= $row['Quotation_Date'];
$ItemID=$row['ItemID'];
$name_of_uploaded_Quotation=$row['name_of_uploaded_Quotation'];
$name_of_uploaded_PR=$row['name_of_uploaded_PR'];
$name_of_uploaded_PO=$row['name_of_uploaded_PO'];
echo <<<EOT
<table class="tool2" id="tool2">
<td><input type="button" value="X" class="delItem" id="delItem$ItemID$ItemCounter" onclick="delForm(this);"></td><td><p><span id="displayCount">$Label</span></p></td>
<tr>
<td align="center" colspan=2 ><b>Quotation Infomation</b></td>
</tr>
<tr>
<td class="title">Supplier : </td><td><input type="text" name="Supplier$ItemCounter" id="Supplier" value=$Supplier></td>
</tr>
<tr>
<td class="title">Quotation upload : </td><td>
EOT;
if($name_of_uploaded_Quotation==''){
echo <<<EOT
<input type="file" name="QuotationUpload$ItemCounter" id="QuotationUpload">
EOT;
}
else {
echo <<<EOT
<p id="linkQu$ItemCounter"><a id="urllinkQu$ItemCounter" href="downloads/$name_of_uploaded_Quotation" target="_blank">$name_of_uploaded_Quotation</a>
<span><input type="button" value="X" class="delItem" id="delqu$ItemID$ItemCounter" onclick="delUpload(this);">
<input type="hidden" name="QuotationUpload$ItemCounter" id="QuotationUpload$ItemCounter" value=$name_of_uploaded_Quotation></p>
EOT;
}
echo <<<EOT
</td>
</tr>
<input type="hidden" name="Quotation_Date$ItemCounter" id="Quotation_Date" value=$Quotation_Date>
<tr>
<td class="title">Order ID : </td><td><input type="text" name="OrderID$ItemCounter" id="OrderID"></td>
</tr>
<tr>
<td class="title">Per Unit Cost : </td><td><input type="text" name="PUC$ItemCounter" id="PUC" value=$PUC></td>
</tr>
<tr>
<td class="title">Total Cost : </td><td><input type="text" name="Total$ItemCounter" id="Total" value=$Total></td>
</tr>
<tr>
<td align="center" colspan=2 ><b>Finance Information</b></td>
</tr>
<tr>
<td class="title">WBS : </td><td><input type="text" name="WBS$ItemCounter" id="WBS" value=$WBS></td>
</tr>
<tr>
<td class="title">Asset Number : </td><td><input type="text" name="AssetNumber$ItemCounter" id="AssetNumber" value=$AssetNumber></td>
</tr>
<tr>
<td align="center" colspan=2 ><b>Delivery Information</b></td>
</tr>
<tr>
<td class="title">PR : </td><td><input type="text" name="PR$ItemCounter" id="PR" value=$PR></td>
</tr>
<tr>
<td class="title">PR upload : </td><td>
EOT;
if($name_of_uploaded_PR==''){
echo <<<EOT
<input type="file" name="PRUpload$ItemCounter" id="PRUpload">
EOT;
}
else {
echo <<<EOT
<p id="linkPR$ItemCounter"><a id="urllinkPR$ItemCounter" href="downloads/$name_of_uploaded_PR" target="_blank">$name_of_uploaded_PR</a>
<input type="button" value="X" class="delItem" id="delpr$ItemID$ItemCounter" onclick="delUpload(this);">
<input type="hidden" name="PRUpload$ItemCounter" id="PRUpload$ItemCounter" value=$name_of_uploaded_PR></p>
EOT;
}
echo <<<EOT
</td>
</tr>
<input type="hidden" name="PR_Date$ItemCounter" id="PR_Date" value=$PR_Date>
<tr>
<td class="title">CCP Approval : </td><td><select class="entry" name="CCP$ItemCounter" id="CCP">
EOT;
foreach ($CCPArray as $key => $value)
{
if($value==$CCP){
echo '<OPTION value='.$value.' selected> '.$value.'';
}
else{
echo '<OPTION value='.$value.'> '.$value.'';
}
}
echo <<<EOT
</select></td>
</tr>
<tr>
<td class="title">PO : </td><td><input type="text" name="PO$ItemCounter" id="PO" value=$PO></td>
</tr>
<tr>
<td class="title">PO upload : </td><td>
EOT;
if($name_of_uploaded_PO==''){
echo <<<EOT
<input type="file" name="POUpload$ItemCounter" id="POUpload">
EOT;
}
else {
echo <<<EOT
<p id="linkPO$ItemCounter"><a id="urllinkPO$ItemCounter" href="downloads/$name_of_uploaded_PO" target="_blank">$name_of_uploaded_PO</a>
<input type="button" value="X" class="delItem" id="delpo$ItemID$ItemCounter" onclick="delUpload(this);">
<input type="hidden" name="POUpload$ItemCounter" id="POUpload$ItemCounter" value=$name_of_uploaded_PO></p>
EOT;
}
echo <<<EOT
</td>
</tr>
<input type="hidden" name="PO_Date$ItemCounter" id="PO_Date" value=$PO_Date>
<tr>
<td class="title">Expected Delivery : </td><td><input type="text" name="ExpectedDelivery$ItemCounter" id="ExpectedDelivery" value=$ExpectedDelivery></td>
</tr>
<input type="hidden" name="Shipment_Date$ItemCounter" id="Shipment_Date" value=$Shipment_Date>
<tr>
<td class="title">Remarks : </td><td><textarea class="entry" name="Remarks$ItemCounter" id="Remarks">$Remarks</textarea></td>
</tr>
<input type="hidden" name="ItemID$ItemCounter" id="ItemID" value=$ItemID>
<br></table></div>
EOT;
$ItemCounter++;
}
echo <<<EOT
<table>
<input type="hidden" name="lastSectionCount" value=$ItemCount id="lastSectionCount">
<input type="hidden" name="OriginalItemCount" value=$ItemCount id="OriginalItemCount">
<input type="hidden" name="ItemCount" value=$ItemCount id="ItemCount">
<input type="hidden" name="Status" value=$Status>
<input type="hidden" name="Pg" value="UpdateOrder_Store">
<input type="hidden" name="Role" value=$Role id="Role">
<input type="hidden" name="RequestID" value=$RequestID id="RequestID">
<input type="hidden" name="Xexv" value=$Xexv id="Xexv">
<input type="hidden" name="UserID" value=$UserID id="UserID">
<p id="hidden"><!-- Insert Hidden input tag here --></p>
</table>
<table>
<tr>
<td width="50%"><input type="submit" class="bluebutton" value="Submit"></td>
<td><input type="button" value="Delete" class="delete" id="delete" onclick="delete_order();"></td>
<td><input type="button" value="Add Sub-Item" class="subItem" id="subItem" onclick="addForm();"></td>
</tr>
</table>
</form>
<div id="clone" style="display: none;">
<table class="tool2" id="tool2">
<td><input type="button" value="X" class="delItem" id="delItem21" onclick="delForm(this);"></td><td><p><span id="displayCount">Main Item</span></p></td>
<tr>
<td align="center" colspan=2 ><b>Quotation Infomation</b></td>
</tr>
<tr>
<td class="title">Supplier : </td><td><input type="text" name="Supplier1" id="Supplier" value=></td>
</tr>
<tr>
<td class="title">Quotation upload : </td><td>
<input type="file" name="QuotationUpload1" id="QuotationUpload">
</td>
</tr>
<input type="hidden" name="Quotation_Date1" id="Quotation_Date" value=0000-00-00>
<tr>
<td class="title">Order ID : </td><td><input type="text" name="OrderID1" id="OrderID"></td>
</tr>
<tr>
<td class="title">Per Unit Cost : </td><td><input type="text" name="PUC1" id="PUC" value=></td>
</tr>
<tr>
<td class="title">Total Cost : </td><td><input type="text" name="Total1" id="Total" value=></td>
</tr>
<tr>
<td align="center" colspan=2 ><b>Finance Information</b></td>
</tr>
<tr>
<td class="title">WBS : </td><td><input type="text" name="WBS1" id="WBS" value=></td>
</tr>
<tr>
<td class="title">Asset Number : </td><td><input type="text" name="AssetNumber1" id="AssetNumber" value=></td>
</tr>
<tr>
<td align="center" colspan=2 ><b>Delivery Information</b></td>
</tr>
<tr>
<td class="title">PR : </td><td><input type="text" name="PR1" id="PR" value=></td>
</tr>
<tr>
<td class="title">PR upload : </td><td>
<input type="file" name="PRUpload1" id="PRUpload">
</td>
</tr>
<input type="hidden" name="PR_Date1" id="PR_Date" value=0000-00-00>
<tr>
<td class="title">CCP Approval : </td><td><select class="entry" name="CCP1" id="CCP"><OPTION value=-Select- selected> -Select-<OPTION value=Yes> Yes<OPTION value=No> No
</select></td>
</tr>
<tr>
<td class="title">PO : </td><td><input type="text" name="PO1" id="PO" value=></td>
</tr>
<tr>
<td class="title">PO upload : </td><td>
<input type="file" name="POUpload1" id="POUpload">
</td>
</tr>
<input type="hidden" name="PO_Date1" id="PO_Date" value=0000-00-00>
<tr>
<td class="title">Expected Delivery : </td><td><input type="text" name="ExpectedDelivery1" id="ExpectedDelivery" value=></td>
</tr>
<input type="hidden" name="Shipment_Date1" id="Shipment_Date" value=0000-00-00>
<tr>
<td class="title">Remarks : </td><td><textarea class="entry" name="Remarks1" id="Remarks"></textarea></td>
</tr>
<input type="hidden" name="ItemID1" id="ItemID" value=2>
<br></table></div>
EOT;
mysql_close($link);
}
的OrderItem表中选择所有查询和结果?提前谢谢。
Integer