Jump to content

newphpcoder

Members
  • Posts

    254
  • Joined

  • Last visited

Everything posted by newphpcoder

  1. Hi.. I resolved it now using thid code: //-----Computation of Working Days---// $sql = "SELECT FromMonth, ToMonth FROM so_month"; $res = mysql_query($sql,$con); $row = mysql_fetch_assoc($res); $FromMonth = $row['FromMonth']; $ToMonth = $row['ToMonth']; function monthNames($from, $to){ $range=array(); for($i=$from; $i<=$to; $i++){ $range[$i]=date('M', mktime(0,0,0,$i)); } return $range; } $month_ = implode("' ', ",monthNames($FromMonth,$ToMonth)); foreach( monthNames($FromMonth, $ToMonth) as $month){ $sql = "SELECT MonthName, SUM(WorkingDays) AS WorkingDays FROM working_days WHERE MonthName IN ('$month') GROUP BY MonthName"; $res = mysql_query($sql, $con); $SumWorkingDays = 0; while($row = mysql_fetch_array($res)){ $WorkingDays+=(int)$row['WorkingDays']; $SumWorkingDays += $WorkingDays; } } Thank you
  2. Hi.. I have forms and I only need to input is the Demanded Qty, and from Demanded Qty that I input it will compute the demanded qty for each Item Code. Now my problem is I don't know on how can it possible that while i input the quantity it will also autodisplay the demanded qty for each materials. Noted: the Demanded Qty that will auto display is display only on the Demanded Qty you input per Items. For Example: On Item = P28 i input demanded qty, only on the ItemCode will display the output. and when i input on P30 the computation will display on the ItemCode for P30. here is my 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); ?> <html> <title>Stock Requisition</title> <head> <link rel="stylesheet" type="text/css" href="kanban.css"> <script type="text/javascript"> function compute_quantity(){ var DemandedQty = document.getElementById('DemandedQty').value; var Quantity = document.getElementById('Quantity').value; var SubQty = (DemandedQty * Quantity); } </script> </head> <body> <form name="stock_requisition" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <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 $DemandedQty = $_POST['DemandedQty']; $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']; $Items_ = substr($Items, 12, 3); echo "<tr> <td style='border: none;font-weight: bold;'> <input type='name' value='$Items_' name='Items_[]' id='Items' readonly = 'readonly' style = 'border:none;width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border:none;'> </td> <td style='border:none;'> </td> <td style='border: none;'><center><input type='text' name='DemandedQty[]' id='DemandedQty' value='' size='12' onkeypress = compute_quantity()></center></td> </tr>"; $sql = "SELECT Items, SubItems, ItemCode, UoM, Class, Description, BINLocation, Quantity FROM bom_subitems WHERE Items = '$Items' ORDER BY Items"or die(mysql_error()); $res_sub = mysql_query($sql, $con); while($row_sub = mysql_fetch_assoc($res_sub)){ $Items1 = $row_sub['Items']; $SubItems = $row_sub['SubItems']; $ItemCode = $row_sub['ItemCode']; $UoM = $row_sub['UoM']; $Class = $row_sub['Class']; $Description = $row_sub['Description']; $BINLocation = $row_sub['BINLocation']; $Quantity = $row_sub['Quantity']; echo "<input type='hidden' name='Quantity' id='Quantity' value='$Quantity'>"; echo "<tr> <td style='border: none;'> <input type='hidden' value='$Items1' id='Items1' name='Items1[]'></td> <td style='border: none;'> <input type='text' name='SubItems[]' value='$SubItems' id='SubItems' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'> <input type='text' name='ItemCode[]' value='$ItemCode' id='ItemCode' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'><center><input type='text' name='SubQty[]' id='SubQty' value='' size='12' style></center></td> <td style='border: none;' size='3'> <input type='text' name='UoM[]' value='$UoM' id='UoM' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='3'></td> <td style='border: none;'> <input type='text' name='Class[]' value='$Class' id='Class' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> <td style='border: none;'> <input type='text' name='Description[]' value='$Description' id='Description' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size= '30'></td> <td style='border: none;'> <input type='text' name='BINLocation[]' value='$BINLocation' id='BINLocation' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;'></td> </tr>"; } } ?> </table> </div> </form> </body> </html> Thank you so much
  3. hi.. i have table and I put style overflow:auto Now, I notice that also the <th> was up when I up the scroll. I just to happen is the <th> will be fix/ not move. only the <tr> here is my code: <div id="kanban_table" style="overflow:auto; height:215px;"> <table> <th> JO No.</th> <th> ETD </th> <th> PO No. </th> <th> SKU Code </th> <th> Description </th> <th> PO Req </th> <th> Priority</th> <?php $sql = "SELECT FromMonth , ToMonth FROM so_month"; $res = mysql_query($sql, $con); $row = mysql_fetch_assoc($res); $FromMonth = $row['FromMonth']; $ToMonth = $row['ToMonth']; $sql = "SELECT ETD, PO_No, SKUCode, Description, POReq FROM sales_order WHERE NOT EXISTS (SELECT PO_No FROM job_order WHERE job_order.PO_No = sales_order.PO_No) AND MONTH(ETD) BETWEEN '$FromMonth' AND '$ToMonth' ORDER BY ETD, PO_No ASC LIMIT 10 "; $res_so = mysql_query($sql, $con); while($row = mysql_fetch_assoc($res_so)){ echo "<form name='joborder_form' action='' method='post'>"; $PO_No = $row['PO_No']; echo "<tr> <td><input type='text' value='' style='border:none;' size='10'></td> <td><input type='text' name='ETD' id='ETD' value='$row[ETD]' style='border:none;' size='10'></td> <td><input type='text' name='PO_No' id='PO_No' value='$row[PO_No]' style='border:none;' size='30'></td> <td><input type='text' name='SKUCode' id='SKUCode' value='$row[sKUCode]' style='border:none;' size='15'></td> <td><input type='text' name='Description' id='Description' value='$row[Description]' style='border:none;' size='35'></td> <td><input type='text' name='POReq' id='POReq' value='$row[POReq]' style='border:none;' size='10'></td> <td><input type='submit' name='priority' value='Approved' id='priority'></td> </tr>"; echo "</form>"; } echo "</table>"; echo "</div>"; Thank you
  4. I tried this: $WorkingDays = 0; while($row = mysql_fetch_array($res)){ $WorkingDays+=(int)$row['WorkingDays']; and the output is: 232423 still not 70 tHANK YOU
  5. Hi.. I have table which has a data so_month: FromMonth : 5 ToMonth : 7 and I have table working_days: MonthName May Jun Jul MonthNumber 05 06 07 WorkingDays 23 24 23 Now I have function to get the 3 consecutive months from FromMonth to ToMonth , which as you can see from May to Jul Now I have problem in getting the SUM of Working days. here is my code: <?php $sql = "SELECT FromMonth, ToMonth FROM so_month"; $res = mysql_query($sql,$con); $row = mysql_fetch_assoc($res); $FromMonth = $row['FromMonth']; $ToMonth = $row['ToMonth']; function monthNames($from, $to){ $range=array(); for($i=$from; $i<=$to; $i++){ $range[$i]=date('M', mktime(0,0,0,$i)); } return $range; } $month_ = implode("' ', ",monthNames($FromMonth,$ToMonth)); foreach( monthNames($FromMonth, $ToMonth) as $month){ $sql = "SELECT MonthName, SUM(WorkingDays) AS WorkingDays FROM working_days WHERE MonthName IN ('$month') GROUP BY MonthName"; $res = mysql_query($sql, $con); while($row = mysql_fetch_array($res)){ $WorkingDays = $row['WorkingDays']; } echo $WorkingDays; } ?> the output of this code is: 232423 and when I change this line: $WorkingDays = $row['WorkingDays']; to $WorkingDays += $row['WorkingDays']; the output is: 234770 I correct output should be: 70 Any help is highly appreciated. Thank you very much..
  6. Thank you... I tried this Update Query: \ UPDATE sales_order SET FromMonth = '05', ToMonth = '07' WHERE MONTH(ETD) BETWEEN '05' AND '07' ORDER BY SKUCode; //it did not update table but no error. when i try to select : SELECT ETD FROM sales_order WHERE MONTH(ETD) BETWEEN '05' AND '07'; //it display ETD Why it did not update? Thank you
  7. I just wnat ot know how can I select the first consecutive months without variable to check, I mean whole mysql syntax. Is it possible? Thanks
  8. Now I need to add 3 Months Name below working days. here is my code: <html> <head> <title>Half Shell</title> <link rel="stylesheet" type="text/css" href="kanban.css" /> <?php error_reporting(E_ALL ^ E_NOTICE); 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); ?> <body> <form name="param" action="" method="post" onSubmit="return false"> <div id="fieldset_PS"> <?php echo "<table>"; $sql = "SELECT DISTINCT s.Comp FROM sales_order s, param_settings p WHERE s.Comp = p.Compounds ORDER BY s.Comp"; $res_comp = mysql_query($sql, $con); while($row_comp = mysql_fetch_assoc($res_comp)){ $Comp[] = $row_comp['Comp']; } echo "<tr><th> </th>"; foreach($Comp AS $Comp){ echo "<th>$Comp</th>"; } echo "<tr><td>Total Kg/Compound</td>"; $Compound = array(); $sql = "SELECT DISTINCT s.Comp FROM sales_order s, param_settings p WHERE s.Comp = p.Compounds ORDER BY s.Comp"; $res_comp = mysql_query($sql, $con); while($row_comp = mysql_fetch_assoc($res_comp)){ $Compound[] = $row_comp['Comp']; } foreach($Compound AS $Compound) { $sql_sec = "SELECT SUM(TotalKg) AS TotalKg FROM sales_order WHERE Comp = '$Compound' GROUP BY Comp ORDER BY Comp"; # add error code compliant with the rest of error code management you are already using $result = mysql_query($sql_sec, $con) ; while( $row_sec = mysql_fetch_assoc( $result ) ) { $TotalKg = $row_sec['TotalKg']; echo "<td>$TotalKg</td>"; } } echo "</tr>"; echo "<tr> <td>Working Days</td></tr>"; function monthNames($from, $to){ $range=array(); for($i=$from; $i<=$to; $i++){ $range[$i]=date('M', mktime(0,0,0,$i)); } return $range; } $sql = "SELECT FromMonth, ToMonth FROM so_month"; $res = mysql_query($sql,$con); $row = mysql_fetch_assoc($res); $FromMonth = $row['FromMonth']; $ToMonth = $row['ToMonth']; foreach( monthNames($FromMonth, $ToMonth) as $month){ echo "<tr>$month</tr>";// this part.... } ?> I attach my sample forms and the result of m code. Thank you again
  9. I tried this: <html> <head> <title>Half Shell</title> <link rel="stylesheet" type="text/css" href="kanban.css" /> <?php error_reporting(E_ALL ^ E_NOTICE); 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); ?> <body> <form name="param" action="" method="post" onSubmit="return false"> <div id="fieldset_PS"> <?php echo "<table>"; $sql = "SELECT DISTINCT s.Comp FROM sales_order s, param_settings p WHERE s.Comp = p.Compounds ORDER BY s.Comp"; $res_comp = mysql_query($sql, $con); while($row_comp = mysql_fetch_assoc($res_comp)){ $Comp[] = $row_comp['Comp']; } echo "<tr><th> </th>"; foreach($Comp AS $Comp){ echo "<th>$Comp</th>"; } echo "<tr><td>Total Kg/Compound</td>"; $Compound = array(); $sql = "SELECT DISTINCT s.Comp FROM sales_order s, param_settings p WHERE s.Comp = p.Compounds ORDER BY s.Comp"; $res_comp = mysql_query($sql, $con); while($row_comp = mysql_fetch_assoc($res_comp)){ $Compound[] = $row_comp['Comp']; } foreach($Compound AS $Compound) { $sql_sec = "SELECT SUM(TotalKg) AS TotalKg FROM sales_order WHERE Comp = '$Compound' GROUP BY Comp ORDER BY Comp"; # add error code compliant with the rest of error code management you are already using $result = mysql_query($sql_sec, $con) ; while( $row_sec = mysql_fetch_assoc( $result ) ) { $TotalKg = $row_sec['TotalKg']; echo "<td>$TotalKg</td>"; } } echo "</tr>"; ?> And it works.
  10. Now this is my code: <?php error_reporting(E_ALL ^ E_NOTICE); 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); ?> <html> <head> <title>Sales Order</title> <link rel="stylesheet" type="text/css" href="kanban.css" /> <script type="text/javascript"> function upload_so(){ document.salesorder.action="import_salesorder.php"; document.salesorder.submit(); alert("Sales Order Successfully Uploaded."); window.location="SalesOrder.php"; } function disp(){ var FromMonth = document.getElementById('FromMonth').value; var ToMonth = document.getElementById('ToMonth').value; document.salesorder.action="salesorder.php?FromMonth="+FromMonth+"&ToMonth="+ToMonth; document.salesorder.submit(); } </script> </head> <body> <form enctype="multipart/form-data" action="import_salesorder.php" method="post" name="salesorder"> <div id="upload"> <fieldset> <legend>Upload Sales Order</legend> <input type="hidden" name="MAX_FILE_SIZE" value="10000000000" /> <table width="500"> <tr> <td>Sales Order:</td> <td><input type="file" name="file" /></td> <td><input type="button" value="Upload" onclick="upload_so()"/></td> <a href="import_salesorder.php">up</a> </tr> </table> </fieldset> </div> <input type="hidden" value="<?php echo $date_upload; ?>" id="date_upload" name="date_upload"> </div> <div id="From_Month"> <label>From Month:</label> <select name="FromMonth"> <option value="Select">Select</option> <option value="01" <?php if($_POST['FromMonth'] == '01') echo "selected='selected'"; ?>>January</option> <option value="02" <?php if($_POST['FromMonth'] == '02') echo "selected='selected'"; ?>>February</option> <option value="03" <?php if($_POST['FromMonth'] == '03') echo "selected='selected'"; ?>>March</option> <option value="04" <?php if($_POST['FromMonth'] == '04') echo "selected='selected'"; ?>>April</option> <option value="05" <?php if($_POST['FromMonth'] == '05') echo "selected='selected'"; ?>>May</option> <option value="06" <?php if($_POST['FromMonth'] == '06') echo "selected='selected'"; ?>>June</option> <option value="07" <?php if($_POST['FromMonth'] == '07') echo "selected='selected'"; ?>>July</option> <option value="08" <?php if($_POST['FromMonth'] == '08') echo "selected='selected'"; ?>>August</option> <option value="09" <?php if($_POST['FromMonth'] == '09') echo "selected='selected'"; ?>>September</option> <option value="10" <?php if($_POST['FromMonth'] == '10') echo "selected='selected'"; ?>>October</option> <option value="11" <?php if($_POST['FromMonth'] == '11') echo "selected='selected'"; ?>>November</option> <option value="12" <?php if($_POST['FromMonth'] == '12') echo "selected='selected'"; ?>>December</option> </select> <label>To Month:</label> <select name="ToMonth"> <option value="Select">Select</option> <option value="01" <?php if($_POST['ToMonth'] == '01') echo "selected='selected'"; ?>>January</option> <option value="02" <?php if($_POST['ToMonth'] == '02') echo "selected='selected'"; ?>>February</option> <option value="03" <?php if($_POST['ToMonth'] == '03') echo "selected='selected'"; ?>>March</option> <option value="04" <?php if($_POST['ToMonth'] == '04') echo "selected='selected'"; ?>>April</option> <option value="05" <?php if($_POST['ToMonth'] == '05') echo "selected='selected'"; ?>>May</option> <option value="06" <?php if($_POST['ToMonth'] == '06') echo "selected='selected'"; ?>>June</option> <option value="07" <?php if($_POST['ToMonth'] == '07') echo "selected='selected'"; ?>>July</option> <option value="08" <?php if($_POST['ToMonth'] == '08') echo "selected='selected'"; ?>>August</option> <option value="09" <?php if($_POST['ToMonth'] == '09') echo "selected='selected'"; ?>>September</option> <option value="10" <?php if($_POST['ToMonth'] == '10') echo "selected='selected'"; ?>>October</option> <option value="11" <?php if($_POST['ToMonth'] == '11') echo "selected='selected'"; ?>>November</option> <option value="12" <?php if($_POST['ToMonth'] == '12') echo "selected='selected'"; ?>>December</option> </select> <input type="button" name="display" value="display" onclick="disp()" id="display"> </div> <div id="kanban_table"> <?php echo "<table border='.2'>"; echo "<th>ETD</th> <th>PO No.</th> <th>SKU Code</th> <th>Description</th> <th>PO Req</th> <th>Compound</th> <!--<th>Compound Kg</th>--> "; $FromMonth = $_POST['FromMonth']; $ToMonth = $_POST['ToMonth']; $sql = "INSERT INTO so_month (FromMonth, ToMonth) VALUES ('$FromMonth', '$ToMonth') ON DUPLICATE KEY UPDATE FromMonth = '$FromMonth', ToMonth = '$ToMonth'"; $res = mysql_query($sql,$con); $sql = "SELECT ETD, PO_No, SKUCode, Description, POReq, Comp FROM sales_order WHERE MONTH(ETD) BETWEEN '$FromMonth' AND '$ToMonth' ORDER BY ETD, PO_No"; $res = mysql_query($sql, $con); while($row = mysql_fetch_assoc($res)){ $ETD = $row['ETD']; $PO_No = $row['PO_No']; $SKUCode = $row['SKUCode']; $Description = $row['Description']; $POReq = $row['POReq']; $Comp = $row['Comp']; echo "<tr> <td>$ETD</td> <td>$PO_No</td> <td>$SKUCode</td> <td>$Description</td> <td>$POReq</td> <td>$Comp</td> <!--<td>$CompKg</td>--> <!--<td>$Cloth</td>--> </tr>"; } ?> </div> </form> </body> </html> Thank you
  11. I tried this: function monthNames($from, $to){ $range=array(); for($i=$from; $i<=$to; $i++){ $range[$i]=date('M', mktime(0,0,0,$i)); } return $range; } $sql = "SELECT FromMonth, ToMonth FROM so_month"; $res = mysql_query($sql,$con); $row = mysql_fetch_assoc($res); $FromMonth = $row['FromMonth']; $ToMonth = $row['ToMonth']; foreach( monthNames($FromMonth, $ToMonth) as $month){ echo $month,'<br>'; } and it works.. now my problem how can I put this on my code: <html> <head> <title>Half Shell</title> <link rel="stylesheet" type="text/css" href="kanban.css" /> <?php error_reporting(E_ALL ^ E_NOTICE); 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); ?> <body> <form name="param" action="" method="post" onSubmit="return false"> <div id="fieldset_PS"> <?php echo "<table>"; $sql = "SELECT DISTINCT s.Comp FROM sales_order s, param_settings p WHERE s.Comp = p.Compounds ORDER BY s.Comp"; $res_comp = mysql_query($sql, $con); while($row_comp = mysql_fetch_assoc($res_comp)){ $Comp[] = $row_comp['Comp']; } echo "<tr><th> </th>"; foreach($Comp AS $Comp){ echo "<th>$Comp</th>"; } echo "<tr><td>Total Kg/Compound</td>"; $Compound = array(); $sql = "SELECT DISTINCT s.Comp FROM sales_order s, param_settings p WHERE s.Comp = p.Compounds ORDER BY s.Comp"; $res_comp = mysql_query($sql, $con); while($row_comp = mysql_fetch_assoc($res_comp)){ $Compound[] = $row_comp['Comp']; } foreach($Compound AS $Compound) { $sql_sec = "SELECT SUM(TotalKg) AS TotalKg FROM sales_order WHERE Comp = '$Compound' GROUP BY Comp ORDER BY Comp"; # add error code compliant with the rest of error code management you are already using $result = mysql_query($sql_sec, $con) ; while( $row_sec = mysql_fetch_assoc( $result ) ) { $TotalKg = $row_sec['TotalKg']; echo "<td>$TotalKg</td>"; } } echo "</tr>"; echo "<tr> <td>Working Days</td></tr>"; echo "<tr></tr>"// this part.... ?> Thank you
  12. ok thank you.. Now how can I put the 3 months in table <td> for example: May June Jul Thank you
  13. Now this is my code to delete the previous month. <?php error_reporting(E_ALL ^ E_NOTICE); date_default_timezone_set("Asia/Singapore"); //set the time zone $data = array(); $con = mysql_connect("localhost", "root",""); if (!$con) { die(mysql_error()); } $db = mysql_select_db("mes", $con); if (!$db) { die(mysql_error()); } $sql = "delete from sales_order"; $result = mysql_query($sql); if (!$result) { die(mysql_error()); } function add_employee($ETD,$PO_No,$SKUCode,$Description,$POReq ,$Comp) { global $data; $con = mysql_connect("localhost", "root",""); if (!$con){ die(mysql_error());} $db = mysql_select_db("mes", $con); if (!$db) { die(mysql_error()); } $ETD= $ETD; $PO_No = $PO_No; $SKUCode = $SKUCode; $Description = $Description; $POReq = $POReq; $Comp = $Comp; $sql = "INSERT INTO sales_order (ETD,PO_No,SKUCode,Description,POReq,Comp) VALUES ('$ETD','$PO_No','$SKUCode','$Description','$POReq','$Comp') "; $res_so = mysql_query($sql, $con); $sql = "INSERT INTO sales_order_dump (ETD,PO_No,SKUCode,Description,POReq,Comp) VALUES ('$ETD','$PO_No','$SKUCode','$Description','$POReq','$Comp') ON DUPLICATE KEY UPDATE ETD = '$ETD', PO_No = '$PO_No', SKUCode = '$SKUCode', Description = '$Description', POReq = '$POReq', Comp = '$Comp'" or die(mysql_error()); $res = mysql_query($sql, $con); $data []= array('ETD'=>$ETD,'PO_No'=>$PO_No,'SKUCode'=>$SKUCode,'Description'=>$Description,'POReq'=>$POReq,'Comp'=>$Comp); } if(empty($_FILES['file']['tmp_name'])){ $doc = new DOMDocument(); $dom = $doc->load('Sales1.xml'); $rows = $doc->getElementsByTagName('Row'); global $last_row; $last_row = false; $first_row = true; foreach ($rows as $row) { if ( !$first_row ) { $ETD = ""; $PO_No = ""; $SKUCode = ""; $Description = ""; $POReq = ""; $Comp = ""; $index = 1; $cells = $row->getElementsByTagName( 'Cell' ); foreach( $cells as $cell ) { $ind = $cell->getAttribute( 'Index' ); if ( $ind != null ) $index = $ind; if ( $index == 1 ) $ETD = $cell->nodeValue; if ( $index == 2 ) $PO_No = $cell->nodeValue; if ( $index == 3 ) $SKUCode = $cell->nodeValue; if ( $index == 4 ) $Description = $cell->nodeValue; if ( $index == 5 ) $POReq = $cell->nodeValue; if ( $index == 6 ) $Comp = $cell->nodeValue; $index += 1; } if ($ETD=='' AND $PO_No=='' AND $SKUCode=='' AND $Description=='' AND $POReq=='' AND $Comp=='') { $last_row = true; } else { add_employee($ETD,$PO_No,$SKUCode,$Description, $POReq, $Comp); } } if ($last_row==true) { $first_row = true; } else { $first_row = false; } } } $sql = "SELECT * FROM sales_order"; $res = mysql_query($sql, $con); $row = mysql_fetch_row($res); if($row >= 0){ $sql_del = "DELETE FROM sales_order WHERE MONTH(ETD) = MONTH(NOW())-1"; $res_del = mysql_query($sql_del,$con) or die(mysql_error()); } $sql = "UPDATE sales_order s SET CompKg = (SELECT Bch_Wt FROM param_settings p WHERE s.Comp = p.Compounds ORDER BY p.Compounds), PlugWt = (SELECT Plug_Wt FROM param_settings p WHERE s.Comp = p.Compounds ORDER BY p.Compounds)"; $res = mysql_query($sql, $con); $sql = "UPDATE sales_order SET Doz = ((CompKg * 1000) / PlugWt) / 12 / 2, KgDoz = (CompKg / Doz), TotalKg = (POReq * KgDoz), BatchNeeded = (POReq / Doz) ORDER BY SKUCode"; $res = mysql_query($sql, $con); ?>
  14. this code: echo implode(", ",monthNames(5,7)); get the MonthsName separated my , echo monthNames($FromMonth, $ToMonth) ; want's to display the output from the function
  15. Thats my question how does it possible?without variable? Thank you
  16. I tried this: echo $Month = monthNames($FromMonth, $ToMonth) ; still the output is Array Thank you
  17. you mean this: WHERE date >= "2012-04-01" AND date < "2012-07-01" but I don't have variable with contain those data :2012-04-01 and 2012-07-01 I mean mysql syntax for exampe MONTH(ETD) Thank you
  18. Without variable to check..I mean is their a mysql syntax Thank you
  19. I tried this: function monthNames($from, $to){ $range=array(); for($i=$from; $i<=$to; $i++){ $range[$i]=date('M', mktime(0,0,0,$i)); } return $range; } echo implode(", ",monthNames(5,7)); $sql = "SELECT FromMonth, ToMonth FROM so_month"; $res = mysql_query($sql,$con); $row = mysql_fetch_assoc($res); $FromMonth = $row['FromMonth']; $ToMonth = $row['ToMonth']; echo $FromMonth; echo $ToMonth; echo monthNames($FromMonth, $ToMonth); the output is: May, Jun, Jul57Array it did not read the $FromMonth, $ToMonth why? Thank you
  20. Hi.. I need help in selecting first 3 Consecutive Months from my table ETD which type is Date. for example in my ETD: 2012-04-01 2012-04-01 2012-04-05 2012-04-08 2012-04-08 2012-05-01 2012-05-01 2012-05-05 2012-05-08 2012-05-08 2012-06-01 2012-06-01 2012-06-05 2012-06-08 2012-06-08 2012-07-01 2012-07-01 2012-07-05 2012-07-08 2012-07-08 2012-08-01 2012-08-01 2012-08-05 2012-08-08 2012-08-08 Now from this ETD data: I need to select only are: (from April - June) 2012-04-01 2012-04-01 2012-04-05 2012-04-08 2012-04-08 2012-05-01 2012-05-01 2012-05-05 2012-05-08 2012-05-08 2012-06-01 2012-06-01 2012-06-05 2012-06-08 2012-06-08 Thank you
  21. Hi.. I need help in getting the 3 Months Name from my table field FromMonth and ToMonth. Here is the scenario. First, I select FromMonth and ToMonth. Ex. FromMonth = 5 ToMonth = 7 So it means FromMonth is May ToMonth is July. Now I save the MonthNumber to my database: table- so_month FromMonth = 5 ToMonth = 7 Now I need to get the between Months Name from FromMonth to ToMonth which are (May, June, July). How does it possible? Thank you so much.
  22. I revise again my code: <html> <head> <title>Half Shell</title> <link rel="stylesheet" type="text/css" href="kanban.css" /> <?php error_reporting(E_ALL ^ E_NOTICE); 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); ?> <body> <form name="param" action="" method="post" onSubmit="return false"> <div id="fieldset_PS"> <?php echo "<table>"; $sql = "SELECT DISTINCT s.Comp FROM sales_order s, param_settings p WHERE s.Comp = p.Compounds ORDER BY s.Comp"; $res_comp = mysql_query($sql, $con); while($row_comp = mysql_fetch_assoc($res_comp)){ $Comp[] = $row_comp['Comp']; } echo "<th> </th>"; foreach($Comp AS $Comp){ echo "<th>$Comp</th>"; echo "<tr> <td>Total Kg/Compound</td>"; $sql_sec = "SELECT SUM(TotalKg) AS TotalKg FROM sales_order WHERE Comp = '$Comp' ORDER BY Comp"; $res_sec = mysql_query($sql_sec, $con); while($row_sec = mysql_fetch_assoc($res_sec)){ $TotalKg[] = $row_sec['TotalKg']; } foreach($TotalKg AS $Total){ echo "<td>$Total</td> </tr>"; } } ?> because I duplicate the tr so i remove it. I will attach agin the output still wrong
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.