Hi..
I resolved my issue when i revise my code:
Code:
$sql = "SELECT PCODE, total FROM kanban_checker ORDER BY PCODE";
$res = mysql_query($sql, $con) or die(mysql_error());
while($row = mysql_fetch_assoc($res)){
$PCODE = $row['PCODE'];
$total = $row['total'];
$sql = "SELECT
P28, P28_max, P28_min,
P30, P30_max, P30_min,
P32, P32_max, P32_min,
P33, P33_max, P33_min,
P35, P35_max, P35_min,
P35M, P35M_max, P35M_min,
P35W, P35W_max, P35W_min,
P38, P38_max, P38_min,
P41, P41_max, P41_min,
P42, P42_max, P42_min,
P43, P43_max, P43_min,
P46, P46_max, P46_min,
P47, P47_max, P47_min
FROM parameter_settings";
$res_pcode = mysql_query($sql, $con);
$row = mysql_fetch_assoc($res_pcode);
$P28 = $row['P28'];
$P28_max = $row['P28_max'];
$P28_min = $row['P28_min'];
$P30 = $row['P30'];
$P30_max = $row['P30_max'];
$P30_min = $row['P30_min'];
$P32 = $row['P32'];
$P32_max = $row['P32_max'];
$P32_min = $row['P32_min'];
$P33 = $row['P33'];
$P33_max = $row['P33_max'];
$P33_min = $row['P33_min'];
$P35 = $row['P35'];
$P35_max = $row['P35_max'];
$P35_min = $row['P35_min'];
$P35M = $row['P35M'];
$P35M_max = $row['P35M_max'];
$P35M_min = $row['P35M_min'];
$P35W = $row['P35W'];
$P35W_max = $row['P35W_max'];
$P35W_min = $row['P35W_min'];
$P38 = $row['P38'];
$P38_max = $row['P38_max'];
$P38_min = $row['P38_min'];
$P41 = $row['P41'];
$P41_max = $row['P41_max'];
$P41_min = $row['P41_min'];
$P42 = $row['P42'];
$P42_max = $row['P42_max'];
$P42_min = $row['P42_min'];
$P43 = $row['P43'];
$P43_max = $row['P43_max'];
$P43_min = $row['P43_min'];
$P46 = $row['P46'];
$P46_max = $row['P46_max'];
$P46_min = $row['P46_min'];
$P47 = $row['P47'];
$P47_max = $row['P47_max'];
$P47_min = $row['P47_min'];
if($PCODE == $P28 && $total == $P28_min){
echo $P28_min;
}
else{
echo '';
}
if($PCODE == $P30 && $total == $P30_min){
echo $P30_min;
}
else{
echo '';
}
if($PCODE == $P32 && $total == $P32_min){
echo $P32_min;
}
else{
echo '';
}
if($PCODE == $P33 && $total == $P33_min){
echo $P33_min;
}
else{
echo '';
}
if($PCODE == $P35 && $total == $P35_min){
echo $P35_min;
}
else{
echo '';
}
if($PCODE == $P35M && $total == $P35M_min){
echo $P35M_min;
}
else{
echo '';
}
if($PCODE == $P35W && $total == $P35W_min){
echo $P35W_min;
}
else{
echo '';
}
if($PCODE == $P38 && $total == $P38_min){
echo $P38_min;
}
else{
echo '';
}
if($PCODE == $P41 && $total == $P41_min){
echo $P41_min;
}
else{
echo '';
}
if($PCODE == $P42 && $total == $P42_min){
echo $P42_min;
}
else{
echo '';
}
if($PCODE == $P43 && $total == $P43_min){
echo $P43_min;
}
else{
echo '';
}
if($PCODE == $P46 && $total == $P46_min){
echo $P46_min;
}
else{
echo '';
}
if($PCODE == $P47 && $total == $P47_min){
echo $P47_min;
}
else{
echo '';
}
}
Now my problem is..
How and where i can add this code in my form to display minimum value per Items which Items = PCODE.
here is my code where I need to add the above code:
Code:
<?php
error_reporting(0);
date_default_timezone_set("Asia/Singapore"); //set the time zone
$con = mysql_connect('localhost', 'root','');
if (!$con) {
echo 'failed';
die();
}
mysql_select_db("mes", $con);
$sr_date =date('Y-m-d H:i:s');
$sql = "SELECT sr_number FROM stock_requisition ORDER BY sr_date DESC LIMIT 1";
$result = mysql_query($sql, $con);
if (!$result) {
echo 'failed';
die();
}
$total = mysql_num_rows($result);
if ($total <= 0) {
$currentSRNum = 1;
}
else {
//------------------------------------------------------------------------------------------------------------------
// Stock Number iteration....
$row = mysql_fetch_assoc($result);
$currentSRNum = (int)(substr($row['sr_num'],0,3));
$currentSRYear = (int)(substr($row['sr_num'],2,2));
$currentSRMonth = (int)(substr($row['sr_num'],0,2));
$currentYear = (int)(date('y'));
$currentMonth = (int)(date('m'));
$currentDay = (int)(date('d'));
if ($currentYear == $currentSRYear) {
if ($currentMonth == $currentSRMonth) {
$currentSRNum = $currentSRNum + 1;
}
if ($currentMonth > $currentSRMonth) {
$currentSRNum = 1;
}
if ($currentDay > $currentSRDay) {
$currentSRNum = 1;
}
}
if ($currentYear > $currentRefYear) {
$currentSRNum = 1;
}
}
//------------------------------------------------------------------------------------------------------------------
$yearMonth = date('ymd');
$currentSR = $yearMonth . sprintf("%03d", $currentSRNum);
?>
<html>
<title>Stock Requisition</title>
<head>
</head>
<body>
<div id="ddcolortabs">
<ul>
<li> <a href="ParameterSettings.php" title="Parameter Settings"><span>Parameter Settings</span></a></li>
<li id="current"><a href="StockRequisition.php" title="Stock Requisition"><span>Stock Requisition</span></a></li>
<li style="margin-left: 1px"><a href="kanban_report.php" title="WIP Report"><span>Wip Report</span></a></li>
</ul>
</div>
<div id="SR_date">
<label>Date :</label>
<input type="text" name="sr_date" value="<?php echo $sr_date; ?>" size="16" readonly="readonly">
</div>
<div id="SR_number">
<label>SR# :</label>
<input type="text" name="sr_number" value="<?php echo $currentSR; ?>" size="8" readonly="readonly" style="font-weight: bold;">
<br/>
</div>
<div>
<table>
<thead>
<th>Items</th>
<th>Sub Items</th>
<th>Item Code</th>
<th>Demanded Qty</th>
<th>UoM</th>
<th>Class</th>
<th>Description</th>
<th>BIN Location</th>
</thead>
<?php
$sql = "SELECT DISTINCT Items FROM bom_subitems ORDER BY Items";
$res_bom = mysql_query($sql, $con);
while($row = mysql_fetch_assoc($res_bom)){
$Items = $row['Items'];
echo "<tr>
<td style='border: none;font-weight: bold;'> $row[Items]</td>
</tr>";
$sql = "SELECT SubItems, ItemCode, UoM, Class, Description, BINLocation FROM bom_subitems WHERE Items = '$row[Items]' ORDER BY Items"or die(mysql_error());
$res_sub = mysql_query($sql, $con);
while($row_sub = mysql_fetch_assoc($res_sub)){
echo "<tr>
<td style='border: none;'> </td>
<td style='border: none;'>$row_sub[SubItems]</td>
<td style='border: none;'> $row_sub[ItemCode]</td>
<td style='border: none;'><center><input type='text' name='DemandedQty' id='DemandedQty' value='' size='7'></center></td>
<td style='border: none;' size='3'> $row_sub[UoM]</td>
<td style='border: none;'> $row_sub[Class]</td>
<td style='border: none;'> $row_sub[Description]</td>
<td style='border: none;'> $row_sub[BINLocation]</td>
</tr>";
}
}
?>
</table>
</div>
</body>
</html>
In Demanded Qty i need to display the Minimum if the total = minimum per PCODE/Item per Item.
for example in P28 the total = P28_min then It will display on the 3 textboxes which belong to P28
I attach my sample image.
Thank you..
Bookmarks