Jump to content

newphpcoder

Members
  • Posts

    254
  • Joined

  • Last visited

Everything posted by newphpcoder

  1. can you give me sample using radio button? Thank you
  2. Hi.. I have checkbox and I need to get his value. I create function for checkbox if checkbox is clicked it is true then the checkbox value is H else W. function chk(){ if(document.getElementById('H').checked==true){ var H = document.getElementById('H'). value = H; } else if(document.getElementById('H').checked==false){ var H = document.getElementById('H'). value = W; } } and I have function for save : function ApproveLeaveOP(){ var H = document.getElementById('H').value; document.sampleform.action="AddLeave.php?H="+H; document.sampleform.submit(); } <input type="checkbox" name="H" id="H" value="" onclick="chk()"> I don't know how can I add value to the checkbox if I click the value will be H if not the value is W. I am new in using checkbox. Thank you so much..
  3. Hi.. I have form for leave and now I need to add checkbox for halfday. if checkbox is checked the HOURS_LEAVE = HOURS_LEAVE * 4 because his leave is halfday only. then if checkbox is not check the HOURS_LEAVE = HOURS_LEAVE * 8 . and also if checkbox is check the value is H else W then it also save to database here is my code for LeaveEmp.php <?php include 'config.php'; date_default_timezone_set('Asia/Singapore'); session_start(); $currentEmpID = $_SESSION['empID']; $EMP_NO = $_GET['EMP_NO']; $NAME = $_GET['NAME']; $DATE_LEAVE_FROM = $_GET['DATE_LEAVE_FROM']; $DATE_LEAVE_TO = $_GET['DATE_LEAVE_TO']; $HOURS_LEAVE = $_GET['HOURS_LEAVE']; $Approve = $_GET['Approve']; $TYPE =$_GET['TYPE']; $dateprocess = $_GET['dateprocess']; $DATE_LEAVE = $_GET['DATE_LEAVE']; $EMPNO = $_GET['EMPNO']; function GetDays($StartDate, $EndDate){ $StartDate = date("Y-m-d", strtotime($StartDate)); $EndDate = date("Y-m-d", strtotime($EndDate)); $Days[] = $StartDate; $CurrentDate = $StartDate; while($CurrentDate < $EndDate){ $CurrentDate = date("Y-m-d", strtotime("+1 day", strtotime($CurrentDate))); if(date("w",strtotime($CurrentDate))>0){ $Days[] = $CurrentDate; } } return count($Days); } $HOURS_LEAVE = GetDays($DATE_LEAVE_FROM, $DATE_LEAVE_TO); $smarty->assign('LeaveStatus', array(SickLeave=>'Sick Leave',VacationLeave=>'Vacation Leave',BirthdayLeave=>'Birthday Leave',MaternityLeave=>'Maternity Leave', PaternityLeave=>'Paternity Leave', UnionLeave=>'Union Leave', Holiday=>'Holiday')); $smarty->assign('TYPE', $TYPE); $sql = "SELECT l.EMP_NO, l.DATE_LEAVE_FROM, l.DATE_LEAVE_TO, l.HOURS_LEAVE, l.TYPE_LEAVE, l.STATUS_LEAVE FROM $ADODB_DB.employment em, $PAYROLL.leave_data l WHERE em.EMP_NO = l.EMP_NO AND em.EMP_ID = '$currentEmpID' AND l.DATE_LEAVE_FROM = '$DATE_LEAVE_FROM'"; $result_edit = $conn2->Execute($sql); $DATE_LEAVE_FROM = $result_edit->fields['DATE_LEAVE_FROM']; $DATE_LEAVE_TO = $result_edit->fields['DATE_LEAVE_TO']; $smarty->assign('DATE_LEAVE_FROM', $DATE_LEAVE_FROM); $smarty->assign('DATE_LEAVE_TO', $DATE_LEAVE_TO); $sql = "SELECT l.EMP_NO, p.EMP_ID, CONCAT(LNAME, ', ', FNAME, ' ', MI, '.') AS FULLNAME, l.DATE_LEAVE_FROM, l.DATE_LEAVE_TO, l.HOURS_LEAVE, l.TYPE_LEAVE, l.STATUS_LEAVE FROM $ADODB_DB.PERSONAL p, $ADODB_DB.employment em, $PAYROLL.leave_data l WHERE em.EMP_NO = l.EMP_NO AND p.EMP_ID = em.EMP_ID ORDER BY FULLNAME"; $rs = $conn2->GetAll($sql); $smarty->assign('getleave', $rs); $smarty->display('header_att.tpl'); $smarty->display('LeaveForm.tpl'); $smarty->display('footer.tpl'); ?> here is my code for saving leave: <?php include 'config.php'; date_default_timezone_set('Asia/Singapore'); $currentEmpID = $_SESSION["empID"]; $EMP_NO = $_GET['EMP_NO']; $NAME = $_GET['NAME']; $DATE_LEAVE_FROM = $_GET['DATE_LEAVE_FROM']; $DATE_LEAVE_TO = $_GET['DATE_LEAVE_TO']; $HOURS_LEAVE = $_GET['HOURS_LEAVE']; $TYPE =$_GET['TYPE']; $Approve = $_GET['Approve']; $dateprocess = $_GET['dateprocess']; $today = date("Y-m-d"); function GetDays($StartDate, $EndDate){ $StartDate = date("Y-m-d", strtotime($StartDate)); $EndDate = date("Y-m-d", strtotime($EndDate)); $Days[] = $StartDate; $CurrentDate = $StartDate; while($CurrentDate < $EndDate){ $CurrentDate = date("Y-m-d", strtotime("+1 day", strtotime($CurrentDate))); if(date("w",strtotime($CurrentDate))>0){ $Days[] = $CurrentDate; } } return count($Days); } $HOURS_LEAVE = GetDays($DATE_LEAVE_FROM, $DATE_LEAVE_TO); $HOURS_LEAVE = $HOURS_LEAVE * 8; $smarty->assign('LeaveStatus', array(SickLeave=>'Sick Leave',VacationLeave=>'Vacation Leave',BirthdayLeave=>'Birthday Leave',MaternityLeave=>'Maternity Leave', PaternityLeave=>'Paternity Leave', UnionLeave=>'Union Leave', Holiday=>'Holiday')); $smarty->assign('TYPE', $TYPE); $smarty->assign('DATE_LEAVE_FROM', $DATE_LEAVE_FROM); $smarty->assign('DATE_LEAVE_TO', $DATE_LEAVE_TO); $smarty->assign('EMP_NO', $EMP_NO); $smarty->assign('NAME', $NAME); $smarty->assign('HOURS_LEAVE', $HOURS_LEAVE); $smarty->assign('TYPE', $TYPE); $smarty->assign('dateprocess', $today); $sql = "SELECT EMP_NO, DATE_LEAVE_FROM, DATE_LEAVE_TO, HOURS_LEAVE, TYPE_LEAVE, STATUS_LEAVE, DATE_PROCESS FROM leave_data WHERE EMP_NO = '$EMP_NO' AND DATE_LEAVE_FROM = '$DATE_LEAVE_FROM' AND DATE_LEAVE_TO = '$DATE_LEAVE_TO'"; $RsLeave = $conn2->Execute($sql); $numrowsRsLeave = $RsLeave->RecordCount(); if($numrowsRsLeave > 0){ echo "<script>alert('Transaction has already been process')</script>"; echo "<script>navigate('LeaveEmp.php')</script>"; } else { $sql = "SELECT EMP_NO, DATE_LEAVE_FROM, DATE_LEAVE_TO, HOURS_LEAVE, TYPE_LEAVE, STATUS_LEAVE, DATE_PROCESS FROM leave_data WHERE EMP_NO = '$EMP_NO' AND DATE_LEAVE_FROM = '$DATE_LEAVE_FROM' AND DATE_LEAVE_TO = '$DATE_LEAVE_TO'"; $RsLeave = $conn2->Execute($sql); $saverec['EMP_NO'] = $EMP_NO; $saverec['DATE_LEAVE_FROM'] = $DATE_LEAVE_FROM; $saverec['DATE_LEAVE_TO'] = $DATE_LEAVE_TO; $saverec['HOURS_LEAVE'] = $HOURS_LEAVE; $saverec['TYPE_LEAVE'] = $TYPE; $saverec['STATUS_LEAVE'] = $Approve; $saverec['DATE_PROCESS'] = $today; $insertSQL = $conn2->GetInsertSQL($RsLeave, $saverec); $conn2->Execute($insertSQL); } $sql = "SELECT EMP_NO, DATE_LEAVE_FROM, DATE_LEAVE_TO, HOURS_LEAVE, TYPE_LEAVE, STATUS_LEAVE, DATE_PROCESS FROM leave_log WHERE EMP_NO = '$EMP_NO' AND DATE_LEAVE_FROM = '$DATE_LEAVE_FROM' AND DATE_LEAVE_TO = '$DATE_LEAVE_TO'"; $RsLeaveLog = $conn2->Execute($sql); $numrowsRsLeave = $RsLeaveLog->RecordCount(); if($numrowsRsLeave > 0){ echo "<script>alert('Transaction has already been process')</script>"; echo "<script>navigate('LeaveEmp.php')</script>"; } else{ $sql = "SELECT EMP_NO, DATE_LEAVE_FROM, DATE_LEAVE_TO, HOURS_LEAVE, TYPE_LEAVE, STATUS_LEAVE, DATE_PROCESS FROM leave_log WHERE EMP_NO = '$EMP_NO' AND DATE_LEAVE_FROM = '$DATE_LEAVE_FROM' AND DATE_LEAVE_TO = '$DATE_LEAVE_TO'"; $RsLeaveLog = $conn2->Execute($sql); $saverec['EMP_NO'] = $EMP_NO; $saverec['DATE_LEAVE_FROM'] = $DATE_LEAVE_FROM; $saverec['DATE_LEAVE_TO'] = $DATE_LEAVE_TO; $saverec['HOURS_LEAVE'] = $HOURS_LEAVE; $saverec['TYPE_LEAVE'] = $TYPE; $saverec['STATUS_LEAVE'] = $Approve; $saverec['DATE_PROCESS'] = $today; $insertSQL = $conn2->GetInsertSQL($RsLeaveLog, $saverec); $conn2->Execute($insertSQL); } session_write_close(); header("Location:LeaveEmp.php"); exit(); ?> And here is the LeaveForm.tpl <script> window.onload = function() { var ul = document.getElementById('searchpayroll'); var links = ul.getElementsByTagName('a'); var i = 0; document.onkeyup = function(e){ e = window.event || e; var key = e.charCode || e.keyCode; if (key == 40) { if (i < links.length - 1) i++; links[i].focus(); } else if (key == 38) { if (i > 0) i--; links[i].focus(); } } } function ApproveLeaveOP(){ var EMP_NO = document.getElementById('EMP_NO').value; var DATE_LEAVE_FROM = document.getElementById('DATE_LEAVE_FROM').value; var DATE_LEAVE_TO = document.getElementById('DATE_LEAVE_TO').value; var NAME = document.getElementById('NAME').value; var HOURS_LEAVE = document.getElementById('HOURS_LEAVE').value; var Approve = document.getElementById('Approve').value; var TYPE = document.getElementById('TYPE').value; var dateprocess = document.getElementById('dateprocess').value; var H = document.getElementById('H').value; document.sampleform.action="AddLeave.php?EMP_NO="+EMP_NO+"&DATE_LEAVE_FROM="+DATE_LEAVE_FROM+"&DATE_LEAVE_TO="+DATE_LEAVE_TO+"&NAME="+NAME+"&HOURS_LEAVE="+HOURS_LEAVE+"&Approve="+Approve+"&TYPE="+TYPE+"&dateprocess="+dateprocess+"&H="+H; document.sampleform.submit(); } </script> <script type="text/javascript" src="op_from_date_leave.js"> </script> <script type="text/javascript" src="op_from_date_leave_conf2.js"></script> <div id="Search"> <form> <p class="serif"><b>Search Lastname:</b></p> <input type="text" name="search_" size="20" onkeyup="searchEmpLeaveOP(this.value);"> <div> <hr /> <ul id="searchpayroll" style="overflow:auto; height:380px; width:100%; margin-left:2px;"> {section name=co_emp loop=$personalAll} <li><a href="LeaveData.php?queryEmpID={$personalAll[co_emp].EMP_ID}">{$personalAll[co_emp].FULLNAME}</a></li> <hr /> {sectionelse} <li>No records found</li> {/section} </ul> </div> <div id="EmpOTForm"> <fieldset> <legend>Overtime and Leave Form</legend> <input type="button" name="OTbtn" value="Overtime" onclick="OtFrmOP()")> <input type="button" name="Leavebtn" value="Leave" onClick="LeaveOP()"> <p class="serif"> <label id="LeaveEmpIDLabel">EMP ID</label><label id="LeaveNameLabel">NAME</label><label id="FromLeave"><a href="Javascript:showCal('RegCalendar1')">FROM DATE </a></label><label id="DaysLabel"><a href="Javascript:showCal('RegCalendar2')">TO DATE</a></label><label id="TypeLeave">LEAVE TYPE</label><label id="HLeave">H</label> <input type="text" name="EMP_NO" id="EMP_NO" value="{$empno}" size="8" > <input type="text" name="NAME" id="NAME" value="{$fullname}" size="35" > <input type="text" name="DATE_LEAVE_FROM" id="DATE_LEAVE_FROM" value="{$DATE_LEAVE_FROM}" size="9"> <input type="text" name="DATE_LEAVE_TO" id="DATE_LEAVE_TO" value="{$DATE_LEAVE_TO}" size="9"> {html_options id=TYPE name=TYPE options=$LeaveStatus selected=$TYPE style="width:140px;"} <input type="checkbox" name="H" id="H" value=""> <input type="button" name="Approve" value="Approve" id="Approve" onclick="ApproveLeaveOP()"> <input type="button" name="Edit" value="Edit" id="Edit" onclick="EditLeaveOP()"> <input type="hidden" name="dateprocess" id="dateprocess" value="{$dateprocess}"> </p> <input type="hidden" id="HOURS_LEAVE"> </fieldset> <div> <p> <table border="1" class="stat" width="auto"> <tr> <th>EMP ID</th> <th>NAME</th> <th>FROM DATE</th> <th>TO DATE</th> <th># of HOURS</th> <th>TYPE</th> <th>STATUS</th> </tr> {section name=att loop=$getleave} <tr> <td id = "EMPNO">{$getleave[att].EMP_NO}</td> <td >{$getleave[att].FULLNAME}</td> <td id = "DATE_LEAVE" onclick="opleave_edit('{$getleave[att].DATE_LEAVE_FROM}')">{$getleave[att].DATE_LEAVE_FROM}</td> <td >{$getleave[att].DATE_LEAVE_TO}</td> <td >{$getleave[att].HOURS_LEAVE}</td> <td >{$getleave[att].TYPE_LEAVE}</td> <td >{$getleave[att].STATUS_LEAVE}</td> </tr> {/section} </table> </p> </form> </div> </div> </div> I attach the sample form. Thank you
  4. Hi... I have 6 transactions. every transaction has date entry. Now I need to get the last dateentry from DATE_ENTRY_WEIGHING DATE_ENTRY_COMPOUNDING DATE_ENTRY_EXTRUSION DATE_ENTRY_FORMING then insert to DATE_ENTRY_VIRTUAL and DATE_ENTRY_WEIGHING DATE_ENTRY_COMPOUNDING DATE_ENTRY_EXTRUSION DATE_ENTRY_FORMING DATE_ENTRY_DIPPING then insert to DATE_ENTRY_TOTAL. here is my code: $sql = "INSERT INTO kanban_open"; $sql = $sql . " " . "SELECT REFNUM, LOT_CODE, ROUND(SUM(WEIGHING_OUTPUT),2) AS WEIGHING, ROUND(SUM(COMPOUNDING_OUTPUT),2) AS COMPOUNDING, ROUND(SUM(EXTRUSION_OUTPUT),2) AS EXTRUSION, ROUND(SUM(FORMING_OUTPUT),2) AS FORMING, ROUND(SUM(DIPPING_OUTPUT),2) AS DIPPING, ROUND(SUM(MOULDING_OUTPUT),2) AS MOULDING, MAX(DATE_ENTRY_WEIGHING) AS DATE_ENTRY_WEIGHING, MAX(DATE_ENTRY_COMPOUNDING) AS DATE_ENTRY_COMPOUNDING, MAX(DATE_ENTRY_EXTRUSION) AS DATE_ENTRY_EXTRUSION, MAX(DATE_ENTRY_FORMING) AS DATE_ENTRY_FORMING, MAX(DATE_ENTRY_DIPPING) AS DATE_ENTRY_DIPPING, MAX(DATE_ENTRY_MOULDING) AS DATE_ENTRY_MOULDING, [b] MAX(DATE_ENTRY_WEIGHING) AS DATE_ENTRY_VIRTUAL,[/b] MAX(DATE_ENTRY_DIPPING) AS DATE_ENTRY_KANBAN, [b] MAX(DATE_ENTRY_WEIGHING) AS DATE_ENTRY_TOTAL,[/b] ROUND(IF (NOT ISNULL(SUM(COMPOUNDING_OUTPUT)), 0, SUM(WEIGHING_OUTPUT)),2) AS WIP_1, ROUND(IF (NOT ISNULL(SUM(EXTRUSION_OUTPUT)), 0, SUM(COMPOUNDING_OUTPUT)),2) AS WIP_2, ROUND(IF (NOT ISNULL(SUM(FORMING_OUTPUT)), 0, SUM(EXTRUSION_OUTPUT)),2) AS WIP_3, ROUND(IF (NOT ISNULL(SUM(DIPPING_OUTPUT)), 0, SUM(FORMING_OUTPUT)),2) AS WIP_4, ROUND(IF (NOT ISNULL(SUM(MOULDING_OUTPUT)), 0, SUM(DIPPING_OUTPUT)),2) AS WIP_5, ROUND(SUM(MOULDING_OUTPUT),2) AS WIP_6, IF (NOT ISNULL(MAX(DATE_ENTRY_COMPOUNDING)), NULL, MAX(DATE_ENTRY_WEIGHING)) AS DATE_WIP_WEIGHING, IF (NOT ISNULL(MAX(DATE_ENTRY_EXTRUSION)), NULL, MAX(DATE_ENTRY_COMPOUNDING)) AS DATE_WIP_COMPOUNDING, IF (NOT ISNULL(MAX(DATE_ENTRY_FORMING)), NULL, MAX(DATE_ENTRY_EXTRUSION)) AS DATE_WIP_EXTRUSION, IF (NOT ISNULL(MAX(DATE_ENTRY_DIPPING)), NULL, MAX(DATE_ENTRY_FORMING)) AS DATE_WIP_FORMING, IF (NOT ISNULL(MAX(DATE_ENTRY_MOULDING)), NULL, MAX(DATE_ENTRY_DIPPING)) AS DATE_WIP_DIPPING, MAX(DATE_ENTRY_MOULDING) AS DATE_WIP_MOULDING, IF (NOT ISNULL(MAX(DATE_ENTRY_COMPOUNDING)), NULL, MAX(DATE_ENTRY_EXTRUSION)) AS DATE_WIP_VIRTUAL, MAX(DATE_ENTRY_DIPPING) AS DATE_ENTRY_KANBAN, IF (NOT ISNULL(MAX(DATE_ENTRY_COMPOUNDING)), NULL, MAX(DATE_ENTRY_EXTRUSION)) AS DATE_WIP_TOTAL, TIMEDIFF(MAX(DATE_ENTRY_COMPOUNDING), MAX(DATE_ENTRY_WEIGHING)) AS ELAPSED_1, TIMEDIFF(MAX(DATE_ENTRY_EXTRUSION), MAX(DATE_ENTRY_COMPOUNDING)) AS ELAPSED_2, TIMEDIFF(MAX(DATE_ENTRY_FORMING), MAX(DATE_ENTRY_EXTRUSION)) AS ELAPSED_3, TIMEDIFF(MAX(DATE_ENTRY_DIPPING), MAX(DATE_ENTRY_FORMING)) AS ELAPSED_4, TIMEDIFF(MAX(DATE_ENTRY_MOULDING), MAX(DATE_ENTRY_DIPPING)) AS ELAPSED_5 FROM MES_REPORT_MAIN GROUP BY REFNUM HAVING ISNULL(SUM(MOULDING_OUTPUT))"; mysql_query($sql,$con); I hope somebody can help me on this. Thank you so much..
  5. Hi... I have form for saving items into database, but I want only insert item with demanded qty. here is my code: StockRequisition.php <?php error_reporting(0); date_default_timezone_set("Asia/Singapore"); $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; $currentYear = (int)(date('y')); $currentMonth = (int)(date('m')); $currentDay = (int)(date('d')); $currentSRYMD = substr($row['sr_number'], 0, 6); $currentYMD = date("ymd"); if ($currentYMD > $currentSRYMD) { $currentSRNum = 1; } else { $currentSRNum += 1; } } else { $row = mysql_fetch_assoc($result); $currentSRNum = (int)(substr($row['sr_number'],0,3)); $currentSRYear = (int)(substr($row['sr_number'],2,2)); $currentSRMonth = (int)(substr($row['sr_number'],0,2)); $currentSRNum = (int)(substr($row['sr_number'],6,4)); $currentYear = (int)(date('y')); $currentMonth = (int)(date('m')); $currentDay = (int)(date('d')); $currentSRYMD = substr($row['sr_number'], 0, 6); $currentYMD = date("ymd"); if ($currentYMD > $currentSRYMD) { $currentSRNum = 1; } else { $currentSRNum += 1; } } $yearMonth = date('ymd'); $currentSR = $currentYMD . sprintf("%04d", $currentSRNum); ?> <html> <title>Stock Requisition</title> <head> <link rel="stylesheet" type="text/css" href="kanban.css"> <script type="text/javascript"> function save_sr(){ var sr_date = document.getElementById("sr_date").value; var sr_number = document.getElementById("sr_number").value; var Items1 = document.getElementById("Items1").value; var SubItems = document.getElementById("SubItems").value; var ItemCode = document.getElementById("ItemCode").value; var DemandedQty = document.getElementById("DemandedQty").value; var UoM = document.getElementById("UoM").value; var Class = document.getElementById("Class").value; var Description = document.getElementById("Description").value; var BINLocation = document.getElementById("BINLocation").value; var RequestedBy = document.getElementById("RequestedBy").value; var ApprovedBy = document.getElementById("ApprovedBy").value; var ReceivedBy = document.getElementById("ReceivedBy").value; var IssuedBy = document.getElementById("IssuedBy").value; document.stock_requisition.action="StockRequisitionSave.php?sr_date="+sr_date+"&sr_number="+sr_number+"&Items1="+Items1+ "&SubItems="+SubItems+"&ItemCode="+ItemCode+"&DemandedQty="+DemandedQty+"&UoM="+UoM+"&Class="+Class+"&Description="+ Description+"&BINLocation="+BINLocation+"&RequestedBy="+RequestedBy+"&ApprovedBy="+ApprovedBy+"&ReceivedBy="+ReceivedBy+ "&IssuedBy="+IssuedBy; document.stock_requisition.submit(); alert("Stock Requisition data save."); window.location = "StockRequisition.php"; } function disp(){ document.stock_requisition.action="StockRequisitionDisplay.php"; document.stock_requisition.submit(); } </script> </head> <body> <form name="stock_requisition" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <div id="ddcolortabs"> <ul> <li> <a href="ParameterSettings.php" title="Parameter Settings"><span>Parameter Settings</span></a></li> <li style="margin-left: 1px"><a href="kanban_report.php" title="WIP Report"><span>Wip Report</span></a></li> <li><a href="fsn.php" title="Finished Stock Note"><span>WMS FG</span></a></li> <li id="current"><a href="StockRequisition.php" title="WMS RM"><span>WMS RM</span></a></li> </ul> </div> <div id="ddcolortabs1"> <ul> <li><a href="ReceivingMaterials.php" title="Receiving Materials"><span>Receiving Materials</span></a></li> <li><a href="Shelving.php" title="Shelving"><span>Shelving</span></a></li> <li id="current"><a href="StockRequisition.php" title="Stock Requisition"><span>Stock Requisition</span></a></li> </ul> </div> <div id="SR_date"> <label>Date :</label> <input type="text" name="sr_date" value="<?php echo $sr_date; ?>"> </div> <div id="SR_number"> <label>SR# :</label> <input type="text" name="sr_number" value="<?php echo $currentSR; ?>"> <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;'> <input type='name' value='$Items' name='Items' id='Items'></td> </tr>"; $sql = "SELECT Items, SubItems, ItemCode, UoM, Class, Description, BINLocation 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']; 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;></td> <td style='border: none;'> <input type='text' name='ItemCode[]' value='$ItemCode' id='ItemCode' readonly='readonly' style='border:none; width:auto;></td> <td style='border: none;'><center><input type='text' name='DemandedQty[]' id='DemandedQty' value='' size='7'></center></td> <td style='border: none;' size='3'> <input type='text' name='UoM[]' value='$UoM' id='UoM' readonly='readonly' style='border:none; width:auto;></td> <td style='border: none;'> <input type='text' name='Class[]' value='$Class' id='Class' readonly='readonly' style='border:none; width:auto;></td> <td style='border: none;'> <input type='text' name='Description[]' value='$Description' id='Description' readonly='readonly' style='border:none; width:auto;></td> <td style='border: none;'> <input type='text' name='BINLocation[]' value='$BINLocation' id='BINLocation' readonly='readonly' style='border:none; width:auto;></td> </tr>"; } } ?> </table> </div> <?php $RequestedBy = array('AAA', 'BBB'); $ApprovedBy = array('EEE', 'FFF'); $ReceivedBy = array('III', 'JJJ'); $IssuedBy = array('MMM', 'NNN'); ?> <div id='Requested_By'> <label>Requested By:</label> <select name="RequestedBy"> <option value="Select">Select</option> <option value="AAA" <?php if($_POST['RequestedBy'] == 'AAA') echo "selected='selected'"; ?>>AAA</option> <option value="BBB" <?php if($_POST['RequestedBy'] == 'BBB') echo "selected='selected'"; ?>>BBB</option> </select> </div> <div id='Approved_By'> <label>Approved By:</label> <select name="ApprovedBy"> <option name='Select'>Select</option> <option value="EEE" <?php if($_POST['ApprovedBy'] == 'EEE') echo "selected='selected'"; ?>>EEE</option> <option value="FFF" <?php if($_POST['ApprovedBy'] == 'FFF') echo "selected='selected'"; ?>>FFF</option> </select> </div> <div id='Received_By'> <label>Issued By:</label> <select name="IssuedBy"> <option name='Select'>Select</option> <option value="III" <?php if($_POST['ReceivedBy'] == 'III') echo "selected='selected'"; ?>>III</option> <option value="JJJ" <?php if($_POST['ReceivedBy'] == 'JJJ') echo "selected='selected'"; ?>>JJJ</option> </select> </div> <div id='Issued_By'> <label>Received By:</label> <select name="ReceivedBy"> <option name='Select'>Select</option> <option value="MMM" <?php if($_POST['IssuedBy'] == 'MMM') echo "selected='selected'"; ?>>MMM</option> <option value="NNN" <?php if($_POST['IssuedBy'] == 'NNN') echo "selected='selected'"; ?>>NNN</option> </select> </div> <div id="save_btn"> <input type="button" name="button" value="save" onClick="save_sr()" style="width: 5em;"> <input type="button" name="button" value="display" onclick="disp()"> </div> </form> </body> </html> and here is my database: <?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 = $_POST['sr_date']; $sr_number = $_POST['sr_number']; $Items1 = $_POST['Items1']; $SubItems = $_POST['SubItems']; $ItemCode = $_POST['ItemCode']; $DemandedQty = $_POST['DemandedQty']; $UoM = $_POST['UoM']; $Class = $_POST['Class']; $Description = $_POST['Description']; $BINLocation = $_POST['BINLocation']; $RequestedBy = $_POST['RequestedBy']; $ApprovedBy = $_POST['ApprovedBy']; $ReceivedBy = $_POST['ReceivedBy']; $IssuedBy = $_POST['IssuedBy']; for($i = 0; $i < count($Items1); $i++) { $sql = "INSERT INTO stock_requisition (sr_date, sr_number, Items, SubItems, ItemCode, DemandedQty, UoM, Class, Description, BINLocation, RequestedBy, ApprovedBy, ReceivedBy, IssuedBy) VALUES ('$sr_date', '$sr_number', '$Items1[$i]', '$SubItems[$i]', '$ItemCode[$i]', '$DemandedQty[$i]', '$UoM[$i]', '$Class[$i]', '$Description[$i]', '$BINLocation[$i]', '$RequestedBy', '$ApprovedBy', '$ReceivedBy', '$IssuedBy') "; $result = mysql_query($sql, $con); } ?> I attach my sample form. I need to save only the P28.. I just want to save only item with data in demanded quantity Thank you
  6. Hi.. I just want to know what is the code to get the last inserted row on database. I tried max and last_insert_id yet it did not solve my problem SELECT last_insert_id(sr_number), sr_date, Items, SubItems, ItemCode, DemandedQty FROM stock_requisition; it display all data from my database. SELECT max(sr_number), sr_date, Items, SubItems, ItemCode, DemandedQty FROM stock_requisition; it only display last row.. but I need to display all data with all data with same sr_number for example : 1204100002 I attach my sample data from my database: Thank you so much
  7. Hi.. Sorry, if I need to repost my problem in while loop. cause until now I can't resolve my problem in saving all data from while loop. I have this code StockRequisition.php where FORM was displayed. <?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; $currentYear = (int)(date('y')); $currentMonth = (int)(date('m')); $currentDay = (int)(date('d')); $currentSRYMD = substr($row['sr_number'], 0, 6); $currentYMD = date("ymd"); if ($currentYMD > $currentSRYMD) { $currentSRNum = 1; } else { $currentSRNum += 1; } } else { //------------------------------------------------------------------------------------------------------------------ // Stock Number iteration.... $row = mysql_fetch_assoc($result); $currentSRNum = (int)(substr($row['sr_number'],0,3)); $currentSRYear = (int)(substr($row['sr_number'],2,2)); $currentSRMonth = (int)(substr($row['sr_number'],0,2)); $currentSRNum = (int)(substr($row['sr_number'],6,4)); $currentYear = (int)(date('y')); $currentMonth = (int)(date('m')); $currentDay = (int)(date('d')); $currentSRYMD = substr($row['sr_number'], 0, 6); $currentYMD = date("ymd"); if ($currentYMD > $currentSRYMD) { $currentSRNum = 1; } else { $currentSRNum += 1; } } //------------------------------------------------------------------------------------------------------------------ $yearMonth = date('ymd'); $currentSR = $currentYMD . sprintf("%04d", $currentSRNum); ?> <html> <title>Stock Requisition</title> <head> <link rel="stylesheet" type="text/css" href="kanban.css"> <script type="text/javascript"> function save_sr(){ var sr_date = document.getElementById("sr_date").value; var sr_number = document.getElementById("sr_number").value; var Items1 = document.getElementById("Items1").value; var SubItems = document.getElementById("SubItems").value; var ItemCode = document.getElementById("ItemCode").value; var DemandedQty = document.getElementById("DemandedQty").value; var UoM = document.getElementById("UoM").value; var Class = document.getElementById("Class").value; var Description = document.getElementById("Description").value; var BINLocation = document.getElementById("BINLocation").value; var RequestedBy = document.getElementById("RequestedBy").value; var ApprovedBy = document.getElementById("ApprovedBy").value; var ReceivedBy = document.getElementById("ReceivedBy").value; var IssuedBy = document.getElementById("IssuedBy").value; document.stock_requisition.action="StockRequisitionSave.php?sr_date="+sr_date+"&sr_number="+sr_number+"&Items1="+Items1+ "&SubItems="+SubItems+"&ItemCode="+ItemCode+"&DemandedQty="+DemandedQty+"&UoM="+UoM+"&Class="+Class+"&Description="+ Description+"&BINLocation="+BINLocation+"&RequestedBy="+RequestedBy+"&ApprovedBy="+ApprovedBy+"&ReceivedBy="+ReceivedBy+ "&IssuedBy="+IssuedBy; document.stock_requisition.submit(); alert("Stock Requisition data save."); window.location = "StockRequisition.php"; } </script> </head> <body> <form name="stock_requisition" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <div id="ddcolortabs"> <ul> <li> <a href="ParameterSettings.php" title="Parameter Settings"><span>Parameter Settings</span></a></li> <li style="margin-left: 1px"><a href="kanban_report.php" title="WIP Report"><span>Wip Report</span></a></li> <li><a href="fsn.php" title="Finished Stock Note"><span>WMS FG</span></a></li> <li id="current"><a href="StockRequisition.php" title="WMS RM"><span>WMS RM</span></a></li> </ul> </div> <div id="ddcolortabs1"> <ul> <li><a href="ReceivingMaterials.php" title="Receiving Materials"><span>Receiving Materials</span></a></li> <li><a href="Shelving.php" title="Shelving"><span>Shelving</span></a></li> <li id="current"><a href="StockRequisition.php" title="Stock Requisition"><span>Stock Requisition</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" style="border: none;"> </div> <div id="SR_number"> <label>SR# :</label> <input type="text" name="sr_number" value="<?php echo $currentSR; ?>" size="10" readonly="readonly" style="font-weight: bold; border: none;"> <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;'> <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;' size='5'></td> </tr>"; $sql = "SELECT Items, SubItems, ItemCode, UoM, Class, Description, BINLocation 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']; 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;' size='10'></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;' size='10'></td> <td style='border: none;'><center><input type='text' name='DemandedQty' id='DemandedQty' value='' size='7'></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;' size='10'></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='10'></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;' size='10'></td> </tr>"; } } ?> </table> </div> <?php $RequestedBy = array('AAA', 'BBB', 'CCC', 'DDD'); $ApprovedBy = array('EEE', 'FFF', 'GGG', 'HHH'); $ReceivedBy = array('III', 'JJJ', 'KKK', 'LLL'); $IssuedBy = array('MMM', 'NNN', 'OOO', 'PPP'); ?> <div id='Requested_By'> <label>Requested By:</label> <select name="RequestedBy"> <option value="Select">Select</option> <option value="AAA" <?php if($_POST['RequestedBy'] == 'AAA') echo "selected='selected'"; ?>>AAA</option> <option value="BBB" <?php if($_POST['RequestedBy'] == 'BBB') echo "selected='selected'"; ?>>BBB</option> <option value="CCC" <?php if($_POST['RequestedBy'] == 'CCC') echo "selected='selected'"; ?>>CCC</option> <option value="DDD" <?php if($_POST['RequestedBy'] == 'DDD') echo "selected='selected'"; ?>>DDD</option> </select> </div> <div id='Approved_By'> <label>Approved By:</label> <select name="ApprovedBy"> <option name='Select'>Select</option> <option value="EEE" <?php if($_POST['ApprovedBy'] == 'EEE') echo "selected='selected'"; ?>>EEE</option> <option value="FFF" <?php if($_POST['ApprovedBy'] == 'FFF') echo "selected='selected'"; ?>>FFF</option> <option value="GGG" <?php if($_POST['ApprovedBy'] == 'GGG') echo "selected='selected'"; ?>>GGG</option> <option value="HHH" <?php if($_POST['ApprovedBy'] == 'HHH') echo "selected='selected'"; ?>>HHH</option> </select> </div> <div id='Received_By'> <label>Issued By:</label> <select name="IssuedBy"> <option name='Select'>Select</option> <option value="III" <?php if($_POST['ReceivedBy'] == 'III') echo "selected='selected'"; ?>>III</option> <option value="JJJ" <?php if($_POST['ReceivedBy'] == 'JJJ') echo "selected='selected'"; ?>>JJJ</option> <option value="KKK" <?php if($_POST['ReceivedBy'] == 'KKK') echo "selected='selected'"; ?>>KKK</option> <option value="LLL" <?php if($_POST['ReceivedBy'] == 'LLL') echo "selected='selected'"; ?>>LLL</option> </select> </div> <div id='Issued_By'> <label>Received By:</label> <select name="ReceivedBy"> <option name='Select'>Select</option> <option value="MMM" <?php if($_POST['IssuedBy'] == 'MMM') echo "selected='selected'"; ?>>MMM</option> <option value="NNN" <?php if($_POST['IssuedBy'] == 'NNN') echo "selected='selected'"; ?>>NNN</option> <option value="OOO" <?php if($_POST['IssuedBy'] == 'OOO') echo "selected='selected'"; ?>>OOO</option> <option value="PPP" <?php if($_POST['IssuedBy'] == 'PPP') echo "selected='selected'"; ?>>PPP</option> </select> </div> <div id="save_btn"> <input type="button" name="button" value="save" onClick="save_sr()"> </div> </form> </body> </html> and here is StockRequisitionSave.php code for saving data to database : <?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 = $_POST['sr_date']; $sr_number = $_POST['sr_number']; $Items1 = $_POST['Items1']; $SubItems = $_POST['SubItems']; $ItemCode = $_POST['ItemCode']; $DemandedQty = $_POST['DemandedQty']; $UoM = $_POST['UoM']; $Class = $_POST['Class']; $Description = $_POST['Description']; $BINLocation = $_POST['BINLocation']; $RequestedBy = $_POST['RequestedBy']; $ApprovedBy = $_POST['ApprovedBy']; $ReceivedBy = $_POST['ReceivedBy']; $IssuedBy = $_POST['IssuedBy']; $sql = "INSERT INTO stock_requisition (sr_date, sr_number, Items, SubItems, ItemCode, DemandedQty, UoM, Class, Description, BINLocation, RequestedBy, ApprovedBy, ReceivedBy, IssuedBy) VALUES ('$sr_date', '$sr_number', '$Items1', '$SubItems', '$ItemCode', '$DemandedQty', '$UoM', '$Class', '$Description', '$BINLocation', '$RequestedBy', '$ApprovedBy', '$ReceivedBy', '$IssuedBy') "; $result = mysql_query($sql, $con); ?> the problem is only the last data was save. I will attach my form. I hope somebody can help me.. I really don't know how can I save all data from form into my database. Thank you so much for your understanding and help.
  8. Hi.. I just want to know how can I save to another table all data that I display using while loop. Now I encountered only one row was save. <?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'); $sr_date = $_GET['sr_date']; $sr_number = $_GET['sr_number']; $Items = $_GET['Items']; $SubItems = $_GET['SubItems']; $ItemCode = $_GET['ItemCode']; $DemandedQty = $_GET['DemandedQty']; $UoM = $_GET['UoM']; $Class = $_GET['Class']; $Description = $_GET['Description']; $BINLocation = $_GET['BINLocation']; $RequestedBy = $_GET['RequestedBy']; $ApprovedBy = $_GET['ApprovedBy']; $ReceivedBy = $_GET['ReceivedBy']; $IssuedBy = $_GET['IssuedBy']; $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 { $row = mysql_fetch_assoc($result); $currentSRNum = (int)(substr($row['sr_number'],0,3)); $currentSRYear = (int)(substr($row['sr_number'],2,2)); $currentSRMonth = (int)(substr($row['sr_number'],0,2)); $currentSRNum = (int)(substr($row['sr_number'],6,4)); $currentYear = (int)(date('y')); $currentMonth = (int)(date('m')); $currentDay = (int)(date('d')); $currentSRYMD = substr($row['sr_number'], 0, 6); $currentYMD = date("ymd"); if ($currentYMD > $currentSRYMD) { $currentSRNum = 1; } else { $currentSRNum += 1; } } //------------------------------------------------------------------------------------------------------------------ $yearMonth = date('ymd'); $currentSR = $currentYMD . sprintf("%04d", $currentSRNum); ?> <html> <title>Stock Requisition</title> <head> <script type="text/javascript"> function save_sr(){ var sr_date = document.getElementById("sr_date").value; var sr_number = document.getElementById("sr_number").value; var Items1 = document.getElementById("Items1").value; var SubItems = document.getElementById("SubItems").value; var ItemCode = document.getElementById("ItemCode").value; var DemandedQty = document.getElementById("DemandedQty").value; var UoM = document.getElementById("UoM").value; var Class = document.getElementById("Class").value; var Description = document.getElementById("Description").value; var BINLocation = document.getElementById("BINLocation").value; var RequestedBy = document.getElementById("RequestedBy").value; var ApprovedBy = document.getElementById("ApprovedBy").value; var ReceivedBy = document.getElementById("ReceivedBy").value; var IssuedBy = document.getElementById("IssuedBy").value; document.stock_requisition.action="StockRequisitionSave.php?sr_date="+sr_date+"&sr_number="+sr_number+"&Items1="+Items1+ "&SubItems="+SubItems+"&ItemCode="+ItemCode+"&DemandedQty="+DemandedQty+"&UoM="+UoM+"&Class="+Class+"&Description="+ Description+"&BINLocation="+BINLocation+"&RequestedBy="+RequestedBy+"&ApprovedBy="+ApprovedBy+"&ReceivedBy="+ReceivedBy+ "&IssuedBy="+IssuedBy; document.stock_requisition.submit(); alert("Stock Requisition data save."); window.location = "StockRequisition.php"; } </script> </head> <body> <form name="stock_requisition" action="<?php echo $_SERVER['PHP_SELF']; ?>" > <div id="ddcolortabs"> <ul> <li> <a href="ParameterSettings.php" title="Parameter Settings"><span>Parameter Settings</span></a></li> <li style="margin-left: 1px"><a href="kanban_report.php" title="WIP Report"><span>Wip Report</span></a></li> <li id="current"><a href="StockRequisition.php" title="WMS RM"><span>WMS RM</span></a></li> </ul> </div> <div id="ddcolortabs1"> <ul> <li><a href="ReceivingMaterials.php" title="Receiving Materials"><span>Receiving Materials</span></a></li> <li><a href="Shelving.php" title="Shelving"><span>Shelving</span></a></li> <li id="current"><a href="StockRequisition.php" title="Stock Requisition"><span>Stock Requisition</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" style="border: none;"> </div> <div id="SR_number"> <label>SR# :</label> <input type="text" name="sr_number" value="<?php echo $currentSR; ?>" size="10" readonly="readonly" style="font-weight: bold; border: none;"> <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;'> <input type='name' value='$row[items]' name='Items' id='Items' readonly = 'readonly' style = 'border:none;width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='5'></td> </tr>"; $sql = "SELECT Items, 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_array($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']; echo "<tr> <td style='border: none;'> <input type='hidden' value='$Items1' id='Items1' name='Items1[]'></td> <!--<td style='border: none;'> <input type='hidden' value='$cast[$i]['id']' 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;' size='10'></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;' size='10'></td> <td style='border: none;'><center><input type='text' name='DemandedQty' id='DemandedQty' value='' size='7'></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;' size='10'></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='10'></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;' size='10'></td> </tr>"; } $sql = "INSERT INTO stock_requisition (sr_date, sr_number, Items, SubItems, ItemCode, DemandedQty, UoM, Class, Description, BINLocation, RequestedBy, ApprovedBy, ReceivedBy, IssuedBy) VALUES ('$sr_date', '$sr_number', '$Items1', '$SubItems', '$ItemCode', '$DemandedQty', '$UoM', '$Class', '$Description', '$BINLocation', '$RequestedBy', '$ApprovedBy', '$ReceivedBy', '$IssuedBy') ON DUPLICATE KEY UPDATE sr_date = '$sr_date', sr_number = '$sr_number', Items = '$Items1', SubItems = '$SubItems', ItemCode = '$ItemCode', DemandedQty = '$DemandedQty', UoM = '$UoM', Class = '$Class', Description = '$Description', BINLocation = '$BINLocation', RequestedBy = '$RequestedBy', ApprovedBy = '$ApprovedBy', ReceivedBy = '$ReceivedBy', IssuedBy = '$IssuedBy'"; $result = mysql_query($sql, $con); } ?> </table> </div> <div id='RequestedBy'> <label>Requested By:</label> <select name="Requested_By"> <option name='None'>Select</option> <option name='AAAAAAAAA'>AAAAAAAAA</option> <option name='BBBBBBBBB'>BBBBBBBBB</option> <option name='CCCCCCCCCC'>CCCCCCCCCC</option> </select> </div> <div id='ApprovedBy'> <label>Approved By:</label> <select name="Approved_By"> <option name='None'>Select</option> <option name='AAAAAAAAA'>AAAAAAAAA</option> <option name='BBBBBBBBB'>BBBBBBBBB</option> <option name='CCCCCCCCCC'>CCCCCCCCCC</option> </select> </div> <div id='ReceivedBy'> <label>Received By:</label> <select name="Received_By"> <option name='None'>Select</option> <option name='AAAAAAAAA'>AAAAAAAAA</option> <option name='BBBBBBBB'>BBBBBBBB</option> <option name='CCCCCCCC'>CCCCCCCC</option> </select> </div> <div id='IssuedBy'> <label>Issued By:</label> <select name="Issued BY"> <option name='None'>Select</option> <option name='AAAAAAAAA'>AAAAAAAAA</option> <option name='BBBBBBBB'>BBBBBBBB</option> <option name='CCCCCCCC'>CCCCCCCC</option> </select> </div> <div id="save_btn"> <input type="button" name="button" value="save" onclick="save_sr()"> </div> </body> </html> I attach the sample form and output. Sorry if I repost my previous thread. I hope somebody can help me. Thank you
  9. I revised again my code. and now only the first row per items was save. 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); $sr_date =date('Y-m-d H:i:s'); $sr_date = $_GET['sr_date']; $sr_number = $_GET['sr_number']; $Items = $_GET['Items']; $SubItems = $_GET['SubItems']; $ItemCode = $_GET['ItemCode']; $DemandedQty = $_GET['DemandedQty']; $UoM = $_GET['UoM']; $Class = $_GET['Class']; $Description = $_GET['Description']; $BINLocation = $_GET['BINLocation']; $RequestedBy = $_GET['RequestedBy']; $ApprovedBy = $_GET['ApprovedBy']; $ReceivedBy = $_GET['ReceivedBy']; $IssuedBy = $_GET['IssuedBy']; $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_number'],0,3)); $currentSRYear = (int)(substr($row['sr_number'],2,2)); $currentSRMonth = (int)(substr($row['sr_number'],0,2)); $currentSRNum = (int)(substr($row['sr_number'],6,4)); $currentYear = (int)(date('y')); $currentMonth = (int)(date('m')); $currentDay = (int)(date('d')); $currentSRYMD = substr($row['sr_number'], 0, 6); $currentYMD = date("ymd"); if ($currentYMD > $currentSRYMD) { $currentSRNum = 1; } else { $currentSRNum += 1; } } //------------------------------------------------------------------------------------------------------------------ $yearMonth = date('ymd'); $currentSR = $currentYMD . sprintf("%04d", $currentSRNum); ?> <html> <title>Stock Requisition</title> <head> <script type="text/javascript"> function save_sr(){ var sr_date = document.getElementById("sr_date").value; var sr_number = document.getElementById("sr_number").value; var Items1 = document.getElementById("Items1").value; var SubItems = document.getElementById("SubItems").value; var ItemCode = document.getElementById("ItemCode").value; var DemandedQty = document.getElementById("DemandedQty").value; var UoM = document.getElementById("UoM").value; var Class = document.getElementById("Class").value; var Description = document.getElementById("Description").value; var BINLocation = document.getElementById("BINLocation").value; var RequestedBy = document.getElementById("RequestedBy").value; var ApprovedBy = document.getElementById("ApprovedBy").value; var ReceivedBy = document.getElementById("ReceivedBy").value; var IssuedBy = document.getElementById("IssuedBy").value; document.stock_requisition.action="StockRequisitionSave.php?sr_date="+sr_date+"&sr_number="+sr_number+"&Items1="+Items1+ "&SubItems="+SubItems+"&ItemCode="+ItemCode+"&DemandedQty="+DemandedQty+"&UoM="+UoM+"&Class="+Class+"&Description="+ Description+"&BINLocation="+BINLocation+"&RequestedBy="+RequestedBy+"&ApprovedBy="+ApprovedBy+"&ReceivedBy="+ReceivedBy+ "&IssuedBy="+IssuedBy; document.stock_requisition.submit(); alert("Stock Requisition data save."); window.location = "StockRequisition.php"; } </script> </head> <body> <form name="stock_requisition" action="<?php echo $_SERVER['PHP_SELF']; ?>" > <div id="ddcolortabs"> <ul> <li> <a href="ParameterSettings.php" title="Parameter Settings"><span>Parameter Settings</span></a></li> <li style="margin-left: 1px"><a href="kanban_report.php" title="WIP Report"><span>Wip Report</span></a></li> <li id="current"><a href="StockRequisition.php" title="WMS RM"><span>WMS RM</span></a></li> </ul> </div> <div id="ddcolortabs1"> <ul> <li><a href="ReceivingMaterials.php" title="Receiving Materials"><span>Receiving Materials</span></a></li> <li><a href="Shelving.php" title="Shelving"><span>Shelving</span></a></li> <li id="current"><a href="StockRequisition.php" title="Stock Requisition"><span>Stock Requisition</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" style="border: none;"> </div> <div id="SR_number"> <label>SR# :</label> <input type="text" name="sr_number" value="<?php echo $currentSR; ?>" size="10" readonly="readonly" style="font-weight: bold; border: none;"> <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;'> <input type='name' value='$row[items]' name='Items' id='Items' readonly = 'readonly' style = 'border:none;width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='5'></td> </tr>"; $sql = "SELECT Items, 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_array($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']; 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;' size='10'></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;' size='10'></td> <td style='border: none;'><center><input type='text' name='DemandedQty[]' id='DemandedQty' value='' size='7'></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;' size='10'></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='10'></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;' size='10'></td> </tr>"; } $sql = "INSERT INTO stock_requisition (sr_date, sr_number, Items, SubItems, ItemCode, DemandedQty, UoM, Class, Description, BINLocation, RequestedBy, ApprovedBy, ReceivedBy, IssuedBy) VALUES ('$sr_date', '$sr_number', '$Items1', '$SubItems', '$ItemCode', '$DemandedQty', '$UoM', '$Class', '$Description', '$BINLocation', '$RequestedBy', '$ApprovedBy', '$ReceivedBy', '$IssuedBy') ON DUPLICATE KEY UPDATE sr_date = '$sr_date', sr_number = '$sr_number', Items = '$Items1', SubItems = '$SubItems', ItemCode = '$ItemCode', DemandedQty = '$DemandedQty', UoM = '$UoM', Class = '$Class', Description = '$Description', BINLocation = '$BINLocation', RequestedBy = '$RequestedBy', ApprovedBy = '$ApprovedBy', ReceivedBy = '$ReceivedBy', IssuedBy = '$IssuedBy'"; $result = mysql_query($sql, $con); } ?> </table> </div> <div id='RequestedBy'> <label>Requested By:</label> <select name="Requested_By"> <option name='None'>Select</option> <option name='AAAAAAAAA'>AAAAAAAAA</option> <option name='BBBBBBBBB'>BBBBBBBBB</option> <option name='CCCCCCCCCC'>CCCCCCCCCC</option> </select> </div> <div id='ApprovedBy'> <label>Approved By:</label> <select name="Approved_By"> <option name='None'>Select</option> <option name='AAAAAAAAA'>AAAAAAAAA</option> <option name='BBBBBBBBB'>BBBBBBBBB</option> <option name='CCCCCCCCCC'>CCCCCCCCCC</option> </select> </div> <div id='ReceivedBy'> <label>Received By:</label> <select name="Received_By"> <option name='None'>Select</option> <option name='AAAAAAAAA'>AAAAAAAAA</option> <option name='BBBBBBBB'>BBBBBBBB</option> <option name='CCCCCCCC'>CCCCCCCC</option> </select> </div> <div id='IssuedBy'> <label>Issued By:</label> <select name="Issued BY"> <option name='None'>Select</option> <option name='AAAAAAAAA'>AAAAAAAAA</option> <option name='BBBBBBBB'>BBBBBBBB</option> <option name='CCCCCCCC'>CCCCCCCC</option> </select> </div> <div id="save_btn"> <input type="button" name="button" value="save" onclick="save_sr()"> </div> </body> </html> Sorry... I really don't know what the solution..how does an array solve my problem. Thank you
  10. Hi... So what code should I need? Thank you so much..
  11. Hi.. I revised my code and I already resolved my problem in select option. Now my problem is how can I save in my database the data that display in a form as same as what it display. Honestly, it's my first time to encounter this kind of saving and i have no idea how possible it is. here is my new 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_number'],0,3)); $currentSRYear = (int)(substr($row['sr_number'],2,2)); $currentSRMonth = (int)(substr($row['sr_number'],0,2)); $currentSRNum = (int)(substr($row['sr_number'],6,4)); $currentYear = (int)(date('y')); $currentMonth = (int)(date('m')); $currentDay = (int)(date('d')); $currentSRYMD = substr($row['sr_number'], 0, 6); $currentYMD = date("ymd"); if ($currentYMD > $currentSRYMD) { $currentSRNum = 1; } else { $currentSRNum += 1; } } $yearMonth = date('ymd'); $currentSR = $currentYMD . sprintf("%04d", $currentSRNum); ?> <html> <title>Stock Requisition</title> <head> <style> #SR_date{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .9em; margin-left: 10px; width: auto; height: auto; float: left; top : 10px; } #SR_number{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .9em; margin-left: 270px; width: auto; height: auto; float: left; top : 10px; } table { margin: 10px; font-family: Arial, Helvetica, sans-serif; font-size: .9em; border: 1px solid #DDD; width: auto; } th { font-family: Arial, Helvetica, sans-serif; font-size: .7em; background: #694; color: #FFF; padding: 2px 6px; border-collapse: separate; border: 1px solid #000; } td { font-family: Arial, Helvetica, sans-serif; font-size: .7em; border: 1px solid #DDD; text-align: left; } #Requested_By{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 10px; width: auto; height: auto; float: left; top : 10px; } #Approved_By{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 15px; width: auto; height: auto; float: left; top : 10px; } #Received_By{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 15px; width: auto; height: auto; float: left; top : 10px; } #Issued_By{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 15px; width: auto; height: auto; float: left; top : 10px; margin-right: 120px; } #save_btn{ position: relative;; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 10px; top: 10px; } </style> <script type="text/javascript"> function save_sr(){ var sr_date = document.getElementById("sr_date").value; var sr_number = document.getElementById("sr_number").value; var Items = document.getElementById("Items").value; var SubItems = document.getElementById("SubItems").value; var ItemCode = document.getElementById("ItemCode").value; var DemandedQty = document.getElementById("DemandedQty").value; var UoM = document.getElementById("UoM").value; var Class = document.getElementById("Class").value; var Description = document.getElementById("Description").value; var BINLocation = document.getElementById("BINLocation").value; var RequestedBy = document.getElementById("RequestedBy").value; var ApprovedBy = document.getElementById("ApprovedBy").value; var ReceivedBy = document.getElementById("ReceivedBy").value; var IssuedBy = document.getElementById("IssuedBy").value; document.stock_requisition.action="StockRequisitionSave.php?sr_date="+sr_date+"&sr_number="+sr_number+"&Items="+Items+ "&SubItems="+SubItems+"&ItemCode="+ItemCode+"&DemandedQty="+DemandedQty+"&UoM="+UoM+"&Class="+Class+"&Description="+ Description+"&BINLocation="+BINLocation+"&RequestedBy="+RequestedBy+"&ApprovedBy="+ApprovedBy+"&ReceivedBy="+ReceivedBy+ "&IssuedBy="+IssuedBy; document.stock_requisition.submit(); alert("Stock Requisition data save."); window.location = "StockRequisition.php"; } </script> </head> <body> <form name="stock_requisition" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <div id="ddcolortabs"> <ul> <li> <a href="ParameterSettings.php" title="Parameter Settings"><span>Parameter Settings</span></a></li> <li style="margin-left: 1px"><a href="kanban_report.php" title="WIP Report"><span>Wip Report</span></a></li> <li id="current"><a href="StockRequisition.php" title="WMS RM"><span>WMS RM</span></a></li> </ul> </div> <div id="ddcolortabs1"> <ul> <li><a href="ReceivingMaterials.php" title="Receiving Materials"><span>Receiving Materials</span></a></li> <li><a href="Shelving.php" title="Shelving"><span>Shelving</span></a></li> <li id="current"><a href="StockRequisition.php" title="Stock Requisition"><span>Stock Requisition</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" style="border: none;"> </div> <div id="SR_number"> <label>SR# :</label> <input type="text" name="sr_number" value="<?php echo $currentSR; ?>" size="10" readonly="readonly" style="font-weight: bold; border: none;"> <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;'> <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;' size='5'></td> </tr>"; $sql = "SELECT SubItems, ItemCode, UoM, Class, Description, BINLocation 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)){ $SubItems = $row_sub['SubItems']; $ItemCode = $row_sub['ItemCode']; $UoM = $row_sub['UoM']; $Class = $row_sub['Class']; $Description = $row_sub['Description']; $BINLocation = $row_sub['BINLocation']; echo "<tr> <td style='border: none;'> </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;' size='10'></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;' size='10'></td> <td style='border: none;'><center><input type='text' name='DemandedQty' id='DemandedQty' value='' size='7'></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;' size='10'></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='10'></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;' size='10'></td> </tr>"; } } ?> </table> </div> <?php $RequestedBy = array('AAA', 'BBB', 'CCC', 'DDD'); $ApprovedBy = array('EEE', 'FFF', 'GGG', 'HHH'); $ReceivedBy = array('III', 'JJJ', 'KKK', 'LLL'); $IssuedBy = array('MMM', 'NNN', 'OOO', 'PPP'); ?> <div id='Requested_By'> <label>Requested By:</label> <select name="RequestedBy"> <option value="Select">Select</option> <option value="AAA" <?php if($_POST['RequestedBy'] == 'AAA') echo "selected='selected'"; ?>>AAA</option> <option value="BBB" <?php if($_POST['RequestedBy'] == 'BBB') echo "selected='selected'"; ?>>BBB</option> <option value="CCC" <?php if($_POST['RequestedBy'] == 'CCC') echo "selected='selected'"; ?>>CCC</option> <option value="DDD" <?php if($_POST['RequestedBy'] == 'DDD') echo "selected='selected'"; ?>>DDD</option> </select> </div> <div id='Approved_By'> <label>Approved By:</label> <select name="ApprovedBy"> <option name='Select'>Select</option> <option value="EEE" <?php if($_POST['ApprovedBy'] == 'EEE') echo "selected='selected'"; ?>>EEE</option> <option value="FFF" <?php if($_POST['ApprovedBy'] == 'FFF') echo "selected='selected'"; ?>>FFF</option> <option value="GGG" <?php if($_POST['ApprovedBy'] == 'GGG') echo "selected='selected'"; ?>>GGG</option> <option value="HHH" <?php if($_POST['ApprovedBy'] == 'HHH') echo "selected='selected'"; ?>>HHH</option> </select> </div> <div id='Received_By'> <label>Received By:</label> <select name="ReceivedBy"> <option name='Select'>Select</option> <option value="III" <?php if($_POST['ReceivedBy'] == 'III') echo "selected='selected'"; ?>>III</option> <option value="JJJ" <?php if($_POST['ReceivedBy'] == 'JJJ') echo "selected='selected'"; ?>>JJJ</option> <option value="KKK" <?php if($_POST['ReceivedBy'] == 'KKK') echo "selected='selected'"; ?>>KKK</option> <option value="LLL" <?php if($_POST['ReceivedBy'] == 'LLL') echo "selected='selected'"; ?>>LLL</option> </select> </div> <div id='Issued_By'> <label>Issued By:</label> <select name="IssuedBy"> <option name='Select'>Select</option> <option value="MMM" <?php if($_POST['IssuedBy'] == 'MMM') echo "selected='selected'"; ?>>MMM</option> <option value="NNN" <?php if($_POST['IssuedBy'] == 'NNN') echo "selected='selected'"; ?>>NNN</option> <option value="OOO" <?php if($_POST['IssuedBy'] == 'OOO') echo "selected='selected'"; ?>>OOO</option> <option value="PPP" <?php if($_POST['IssuedBy'] == 'PPP') echo "selected='selected'"; ?>>PPP</option> </select> </div> <div id="save_btn"> <input type="button" name="button" value="save" onclick="save_sr()"> </div> </body> </html> Any help is higly appreciated. Thank you
  12. Hi.. I need to save data from a while loop and data from select option, Now I encountered that using my query I only save is the last part of my while loop and also the data that I choose in select option did not save. 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); $sr_date =date('Y-m-d H:i:s'); $sr_date = $_POST['sr_date']; $sr_number = $_POST['sr_number']; $Items = $_POST['Items']; $SubItems = $_POST['SubItems']; $ItemCode = $_POST['ItemCode']; $DemandedQty = $_POST['DemandedQty']; $UoM = $_POST['UoM']; $Class = $_POST['Class']; $Description = $_POST['Description']; $BINLocation = $_POST['BINLocation']; $RequestedBy = $_POST['RequestedBy']; $ApprovedBy = $_POST['ApprovedBy']; $ReceivedBy = $_POST['ReceivedBy']; $IssuedBy = $_POST['IssuedBy']; $sql = "INSERT INTO stock_requisition (sr_date, sr_number, Items, SubItems, ItemCode, DemandedQty, UoM, Class, Description, BINLocation, RequestedBy, ApprovedBy, ReceivedBy, IssuedBy) VALUES ('$sr_date', '$sr_number', '$Items', '$SubItems', '$ItemCode', '$DemandedQty', '$UoM', '$Class', '$Description', '$BINLocation', '$RequestedBy', '$ApprovedBy', '$ReceivedBy', '$IssuedBy') ON DUPLICATE KEY UPDATE sr_date = '$sr_date', sr_number = '$sr_number', Items = '$Items', SubItems = '$SubItems', ItemCode = '$ItemCode', DemandedQty = '$DemandedQty', UoM = '$UoM', Class = '$Class', Description = '$Description', BINLocation = '$BINLocation', RequestedBy = '$RequestedBy', ApprovedBy = '$ApprovedBy', ReceivedBy = '$ReceivedBy', IssuedBy = '$IssuedBy'"; $result = mysql_query($sql, $con); $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_number'],0,3)); $currentSRYear = (int)(substr($row['sr_number'],2,2)); $currentSRMonth = (int)(substr($row['sr_number'],0,2)); $currentSRNum = (int)(substr($row['sr_number'],6,4)); $currentYear = (int)(date('y')); $currentMonth = (int)(date('m')); $currentDay = (int)(date('d')); $currentSRYMD = substr($row['sr_number'], 0, 6); $currentYMD = date("ymd"); if ($currentYMD > $currentSRYMD) { $currentSRNum = 1; } else { $currentSRNum += 1; } } //------------------------------------------------------------------------------------------------------------------ $yearMonth = date('ymd'); $currentSR = $currentYMD . sprintf("%04d", $currentSRNum); ?> <html> <title>Stock Requisition</title> <head> <style type="text/css"> #ddcolortabs{ margin-left: 2px; padding: 0; width: 100%; background: transparent; voice-family: "\"}\""; voice-family: inherit; padding-left: 2px; } #ddcolortabs ul{ font: bold 12px Arial, Verdana, sans-serif; margin:0; padding:0; list-style:none; } #ddcolortabs li{ display:inline; margin:0 2px 0 0; padding:0; text-transform:uppercase; } #ddcolortabs a{ float:left; color: white; background: #8cb85c url(layout_image/color_tabs_left.gif) no-repeat left top; margin:2px 2px 0 0; padding:0px 0 1px 3px; text-decoration:none; letter-spacing: 1px; } #ddcolortabs a span{ float:right; display:block; /*background: transparent url(layout_image/color_tabs_right.gif) no-repeat right top;*/ padding:6px 9px 2px 6px; } #ddcolortabs a span{ float:none; } #ddcolortabs a:hover{ background-color: #678b3f; } #ddcolortabs a:hover span{ background-color: #678b3f ; } #ddcolortabs #current a, #ddcolortabs #current span{ /*currently selected tab*/ background-color: #678b3f; } </style> <style type="text/css"> #ddcolortabs1{ position: relative; top: 10px; margin-left: 2px; padding: 0; width: 100%; background: transparent; voice-family: "\"}\""; voice-family: inherit; padding-left: 2px; } #ddcolortabs1 ul{ font: bold 12px Arial, Verdana, sans-serif; margin:0; padding:0; list-style:none; } #ddcolortabs1 li{ display:inline; margin:0 2px 0 0; padding:0; text-transform:uppercase; } #ddcolortabs1 a{ float:left; color: white; background: #8cb85c url(layout_image/color_tabs_left.gif) no-repeat left top; margin:2px 2px 0 0; padding:0px 0 1px 3px; text-decoration:none; letter-spacing: 1px; } #ddcolortabs1 a span{ float:right; display:block; /*background: transparent url(layout_image/color_tabs_right.gif) no-repeat right top;*/ padding:6px 9px 2px 6px; } #ddcolortabs1 a span{ float:none; } #ddcolortabs1 a:hover{ background-color: #678b3f; } #ddcolortabs1 a:hover span{ background-color: #678b3f ; } #ddcolortabs1 #current a, #ddcolortabs1 #current span{ /*currently selected tab*/ background-color: #678b3f; } </style> <style> #SR_date{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .9em; margin-left: 10px; width: auto; height: auto; float: left; top : 10px; } #SR_number{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .9em; margin-left: 270px; width: auto; height: auto; float: left; top : 10px; } table { margin: 10px; font-family: Arial, Helvetica, sans-serif; font-size: .9em; border: 1px solid #DDD; width: auto; } th { font-family: Arial, Helvetica, sans-serif; font-size: .7em; background: #694; color: #FFF; padding: 2px 6px; border-collapse: separate; border: 1px solid #000; } td { font-family: Arial, Helvetica, sans-serif; font-size: .7em; border: 1px solid #DDD; text-align: left; } #RequestedBy{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 10px; width: auto; height: auto; float: left; top : 10px; } #ApprovedBy{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 15px; width: auto; height: auto; float: left; top : 10px; } #ReceivedBy{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 15px; width: auto; height: auto; float: left; top : 10px; } #IssuedBy{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 15px; width: auto; height: auto; float: left; top : 10px; margin-right: 120px; } #save_btn{ position: relative;; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 10px; top: 10px; } </style> <script type="text/javascript"> function save_sr(){ var sr_date = document.getElementById("sr_date").value; var sr_number = document.getElementById("sr_number").value; var Items = document.getElementById("Items").value; var SubItems = document.getElementById("SubItems").value; var ItemCode = document.getElementById("ItemCode").value; var DemandedQty = document.getElementById("DemandedQty").value; var UoM = document.getElementById("UoM").value; var Class = document.getElementById("Class").value; var Description = document.getElementById("Description").value; var BINLocation = document.getElementById("BINLocation").value; var RequestedBy = document.getElementById("RequestedBy").value; var ApprovedBy = document.getElementById("ApprovedBy").value; var ReceivedBy = document.getElementById("ReceivedBy").value; var IssuedBy = document.getElementById("IssuedBy").value; document.stock_requisition.action="StockRequisitionSave.php?sr_date="+sr_date+"&sr_number="+sr_number+"&Items="+Items+ "&SubItems="+SubItems+"&ItemCode="+ItemCode+"&DemandedQty="+DemandedQty+"&UoM="+UoM+"&Class="+Class+"&Description="+ Description+"&BINLocation="+BINLocation+"&RequestedBy="+RequestedBy+"&ApprovedBy="+ApprovedBy+"&ReceivedBy="+ReceivedBy+ "&IssuedBy="+IssuedBy; document.stock_requisition.submit(); alert("Stock Requisition data save."); window.location = "StockRequisition.php"; } </script> </head> <body> <form name="stock_requisition" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <div id="ddcolortabs"> <ul> <li> <a href="ParameterSettings.php" title="Parameter Settings"><span>Parameter Settings</span></a></li> <li style="margin-left: 1px"><a href="kanban_report.php" title="WIP Report"><span>Wip Report</span></a></li> <li id="current"><a href="StockRequisition.php" title="WMS RM"><span>WMS RM</span></a></li> </ul> </div> <div id="ddcolortabs1"> <ul> <li><a href="ReceivingMaterials.php" title="Receiving Materials"><span>Receiving Materials</span></a></li> <li><a href="Shelving.php" title="Shelving"><span>Shelving</span></a></li> <li id="current"><a href="StockRequisition.php" title="Stock Requisition"><span>Stock Requisition</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" style="border: none;"> </div> <div id="SR_number"> <label>SR# :</label> <input type="text" name="sr_number" value="<?php echo $currentSR; ?>" size="10" readonly="readonly" style="font-weight: bold; border: none;"> <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;'> <input type='name' value='$row[items]' name='Items' id='Items' readonly = 'readonly' style = 'border:none;width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='5'></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;'> <input type='text' name='SubItems' value='$row_sub[subItems]' id='SubItems' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='10'></td> <td style='border: none;'> <input type='text' name='ItemCode' value='$row_sub[itemCode]' id='ItemCode' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='10'></td> <td style='border: none;'><center><input type='text' name='DemandedQty' id='DemandedQty' value='' size='7'></center></td> <td style='border: none;' size='3'> <input type='text' name='UoM' value='$row_sub[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='$row_sub[Class]' id='Class' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='10'></td> <td style='border: none;'> <input type='text' name='Description' value='$row_sub[Description]' id='Description' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='10'></td> <td style='border: none;'> <input type='text' name='BINLocation' value='$row_sub[bINLocation]' id='BINLocation' readonly='readonly' style='border:none; width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='10'></td> </tr>"; } } ?> </table> </div> <div id='RequestedBy'> <label>Requested By:</label> <select name="Requested_By"> <option name='None'>Select</option> <option name='AAAAAAAAA'>AAAAAAAAA</option> <option name='BBBBBBBBB'>BBBBBBBBB</option> <option name='CCCCCCCCCC'>CCCCCCCCCC</option> </select> </div> <div id='ApprovedBy'> <label>Approved By:</label> <select name="Approved_By"> <option name='None'>Select</option> <option name='AAAAAAAAA'>AAAAAAAAA</option> <option name='BBBBBBBBB'>BBBBBBBBB</option> <option name='CCCCCCCCCC'>CCCCCCCCCC</option> </select> </div> <div id='ReceivedBy'> <label>Received By:</label> <select name="Received_By"> <option name='None'>Select</option> <option name='AAAAAAAAA'>AAAAAAAAA</option> <option name='BBBBBBBB'>BBBBBBBB</option> <option name='CCCCCCCC'>CCCCCCCC</option> </select> </div> <div id='IssuedBy'> <label>Issued By:</label> <select name="Issued BY"> <option name='None'>Select</option> <option name='AAAAAAAAA'>AAAAAAAAA</option> <option name='BBBBBBBB'>BBBBBBBB</option> <option name='CCCCCCCC'>CCCCCCCC</option> </select> </div> <div id="save_btn"> <input type="button" name="button" value="save" onclick="save_sr()"> </div> </body> </html> I also I attach the display data. Thank you
  13. Hi... I've notice in my code for autogenerate sr number, when no data was save in the database the sr number became 0001 the date did not display. $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_number'],0,3)); $currentSRYear = (int)(substr($row['sr_number'],2,2)); $currentSRMonth = (int)(substr($row['sr_number'],0,2)); $currentSRNum = (int)(substr($row['sr_number'],6,4)); $currentYear = (int)(date('y')); $currentMonth = (int)(date('m')); $currentDay = (int)(date('d')); $currentSRYMD = substr($row['sr_number'], 0, 6); $currentYMD = date("ymd"); if ($currentYMD > $currentSRYMD) { $currentSRNum = 1; } else { $currentSRNum += 1; } } //------------------------------------------------------------------------------------------------------------------ $yearMonth = date('ymd'); $currentSR = $currentYMD . sprintf("%04d", $currentSRNum); it works perfectly if theirs an sr number was already save in my database. Thank you
  14. Hi... I have a problemand I tried to resolved it but still I failed.. I need to add a code in a php file where I'm not the one who code, now I need to add code on that file, and the problem is the one who the owner of code is not here. I need to add code : $sub_lotcode = substr($lotCode, 9, 4); $sql = "SELECT k.PCODE, k.kanban, p.Compounds, p.Max_Lot FROM kanban_checker k, param_settings p WHERE k.kanban = p.Max_Lot AND k.PCODE = '$sub_lotcode' AND p.Compounds = '$sub_lotcode'"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { notify that PCODE reach the maximum } else{ echo "continue"; } here is the code where I need to add this condition: <?php error_reporting(0); $con = mysql_connect('localhost', 'root',''); if (!$con) { echo 'failed'; die(); } mysql_select_db("mes", $con); $lotCode = mysql_real_escape_string($_GET['normal']); $lotCodeDownGrade = mysql_real_escape_string($_GET['downgrade']); $terminalNo = mysql_real_escape_string($_GET['n']); $downMode = mysql_real_escape_string($_GET['down']); //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if ($terminalNo == "1") { if ($lotCode != "") { $sql = "SELECT BARCODE FROM LEGALCODES WHERE BARCODE='$lotCode'"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { echo "X"; // X - for non existent in the mes table } else { //do this if code exist in the database: // //code exist in the database $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND TERMINAL_ID='1' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { echo "0"; // continue to transact } else { // query the last terminal it was used $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND ACTIVE=TRUE ORDER BY DATE_ENTRY DESC LIMIT 1"; $result = mysql_query($sql, $con); $row = mysql_fetch_array($result); $total = mysql_num_rows($result); echo $row['TERMINAL_ID'] ; // already used here - me nakita // GET THE LAST TERMINAL NUMBER ACTIVE ADD 1 HERE TO DISPLAY WHICH TERMINAL TO GO } } } } //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> elseif ($terminalNo == "4") { if ($lotCode != "") { $sql = "SELECT BARCODE FROM LEGALCODES WHERE BARCODE='$lotCode'"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { echo "X"; // X - for non existent in the mes table } else { //if downgrade is checked do this : if ($downMode == "true") { $advanceTerminal = ((integer)($terminalNo) + 1); $advanceTerminal = (string)($advanceTerminal); $preTerminal = ((integer)($terminalNo) - 1); $preTerminal = (string)($preTerminal); //query if the lot code exist in advance terminal .. $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND TERMINAL_ID='$advanceTerminal' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { // check naman kung wala sa naunang terminal $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND TERMINAL_ID='$preTerminal' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND ACTIVE= TRUE ORDER BY TERMINAL_ID DESC LIMIT 1"; $result = mysql_query($sql, $con); $row = mysql_fetch_array($result); $total = mysql_num_rows($result); if ($total <= 0) { // NO RECORDS FOUND GO TO TERMINAL 1 == optional echo "notran"; } else { echo $row['TERMINAL_ID'] ; } } else { $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND TERMINAL_ID='$terminalNo' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0 || $total >= 0) { echo "G"; } } } else { $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND ACTIVE= TRUE ORDER BY TERMINAL_ID DESC LIMIT 1"; $result = mysql_query($sql, $con); $row = mysql_fetch_array($result); $total = mysql_num_rows($result); echo $row['TERMINAL_ID'] ; } } else { //query if the lot code exist in this terminal .. $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND TERMINAL_ID='$terminalNo' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { // wala nakita - then tsek if nag exist sa terminal na sinundan $preTerminal = ((integer)($terminalNo) - 1); $preTerminal = (string)($preTerminal); //then tsek if nag exist sa terminal na sinundan $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND TERMINAL_ID='$preTerminal' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { // walang nakita sa mga naunang terminal // do this if no previous transaction with pre requisite process // query the last terminal it was used $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND ACTIVE= TRUE ORDER BY TERMINAL_ID DESC LIMIT 1"; $result = mysql_query($sql, $con); $row = mysql_fetch_array($result); $total = mysql_num_rows($result); // $row = mysql_fetch_array($result); if ($total <= 0) { // NO RECORDS FOUND GO TO TERMINAL 1 == optional echo "notran"; } else { echo $row['TERMINAL_ID']; // GET THE LAST TERMINAL NUMBER ACTIVE ADD 1 HERE TO DISPLAY WHICH TERMINAL TO GO } } else { echo "G"; } } else { //me record na nakita sa terminal na pinag transakan // query the last terminal it was used $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND ACTIVE=TRUE ORDER BY TERMINAL_ID DESC LIMIT 1"; $result = mysql_query($sql, $con); $row = mysql_fetch_array($result); $total = mysql_num_rows($result); echo $row['TERMINAL_ID'] ; // already used here - me nakita // GET THE LAST TERMINAL NUMBER ACTIVE ADD 1 HERE TO DISPLAY WHICH TERMINAL TO GO } } // here is the terminator of else in downgrade } } //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if ($lotCodeDownGrade != "") { $sql = "SELECT BARCODE FROM LEGALCODES WHERE BARCODE='$lotCodeDownGrade'"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { echo "X"; // X - for non existent in the mes table } else { //do this if code exist in the database: // //code exist in the database $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCodeDownGrade' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { echo "0"; // continue to transact } else { // query the last terminal it was used $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCodeDownGrade' AND ACTIVE=TRUE ORDER BY TERMINAL_ID DESC LIMIT 1"; $result = mysql_query($sql, $con); $row = mysql_fetch_array($result); $total = mysql_num_rows($result); echo $row['TERMINAL_ID'] ; // already used here - me nakita // GET THE LAST TERMINAL NUMBER ACTIVE ADD 1 HERE TO DISPLAY WHICH TERMINAL TO GO } } } } //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> else { if ($lotCode != "") { $sql = "SELECT BARCODE FROM LEGALCODES WHERE BARCODE='$lotCode'"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { echo "X"; // X - for non existent in the mes table } else { //query if the lot code exist in this terminal .. $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND TERMINAL_ID='$terminalNo' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { // wala nakita - then tsek if nag exist sa terminal na sinundan $preTerminal = ((integer)($terminalNo) - 1); $preTerminal = (string)($preTerminal); //then tsek if nag exist sa terminal na sinundan $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND TERMINAL_ID='$preTerminal' AND ACTIVE=TRUE"; $result = mysql_query($sql, $con); $total = mysql_num_rows($result); if ($total <= 0) { // walang nakita sa mga naunang terminal // do this if no previous transaction with pre requisite process // query the last terminal it was used $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND ACTIVE=TRUE ORDER BY TERMINAL_ID DESC LIMIT 1"; $result = mysql_query($sql, $con); $row = mysql_fetch_array($result); $total = mysql_num_rows($result); if ($total <= 0) { // NO RECORDS FOUND GO TO TERMINAL 1 == optional echo "notran"; } else { echo $row['TERMINAL_ID']; // GET THE LAST TERMINAL NUMBER ACTIVE ADD 1 HERE TO DISPLAY WHICH TERMINAL TO GO } } else { echo "G"; } } else { //me record na nakita sa terminal na pinag transakan // query the last terminal it was used $sql = "SELECT LOT_CODE, TERMINAL_ID, ACTIVE FROM DEPENDENCY WHERE LOT_CODE='$lotCode' AND ACTIVE= TRUE ORDER BY TERMINAL_ID DESC LIMIT 1"; $result = mysql_query($sql, $con); $row = mysql_fetch_array($result); $total = mysql_num_rows($result); echo $row['TERMINAL_ID'] ; // already used here - me nakita // GET THE LAST TERMINAL NUMBER ACTIVE ADD 1 HERE TO DISPLAY WHICH TERMINAL TO GO } } } } mysql_close($con); ?> function unUsedLotId(txtElemID){ var txtElemID_Active = txtElemID; //alert("VV" + txtElemID_Active.value + "VV" ); responsePHP = "no_reply"; changeFocus = false; var termNo = terminalNo(); ajaxRequest = remoteRequestObject(); ajaxRequest.onreadystatechange = function(){ if (ajaxRequest.readyState==4 && ajaxRequest.status==200) { // var result = ajaxRequest.responseText; responsePHP = ajaxRequest.responseText; //alert(responsePHP) // if (result=="1") { result = "Already used Tag";} // if (result=="0") { result = "Tag ok";} // if (result=="G") { result = "Tag ok";} // if (result=="B") { result = "Incomplete Process";} // var resultStr = (result=="1") ? 'Tag used or incomplete prerequisites' : 'Tag unused'; if (responsePHP == "failed") { txtElemID_Active.disabled = false; txtElemID_Active.value = ""; txtElemID_Active.focus(); notify("Report to MIS<br /> Please scan again."); } //------------------------------added by rhoda for integration-------------------------------------------------- /* else if (responsePHP == "C"){ notify("CCCC"); if (txtElemID_Active.disabled) { txtElemID_Active.disabled = false; } txtElemID_Active.value = ""; txtElemID_Active.focus(); } */ //-------------------------------------------------------------------------------- else if (responsePHP == "X") { //result = "Lot ID invalid."; //responsePHP = "Lot ID invalid."; notify("Lot ID invalid. Scan Again."); if (txtElemID_Active.disabled) { txtElemID_Active.disabled = false; } txtElemID_Active.value = ""; txtElemID_Active.focus(); } //-------------------------------------------------------------------------------- else if (responsePHP =="0" || responsePHP =="G"){ if (txtElemID_Name == "txtLotCode") { window.LotID = (txtElemID_Active.value) } if (txtElemID_Name == "txtLotCodeDownGrade") { window.LotID_Down = (txtElemID_Active.value) } strip(txtElemID_Active) if (termNo == "1") { isSelected('txtLotCode', 'selWeight_MachineID'); } if (termNo == "2" || termNo == "3") { isSelected('txtLotCode', 'txtKitWeight'); } if (termNo == "4" || termNo == "5" || termNo == "6" || termNo == "7") { //////////////////////////////// downgrade modification /////////////////////////////////////// if (termNo == "4") { //alert(termNo) var chkDownGrade = document.getElementById('chkDownGrade') if (chkDownGrade.checked == 1) { //alert("here") if (txtElemID_Name == 'txtLotCode') { isSelected('txtLotCode', 'txtLotCodeDownGrade'); } if (txtElemID_Name == 'txtLotCodeDownGrade') { isSelected('txtLotCodeDownGrade', 'selMachineID'); } } else { //alert("here") if (txtElemID_Name == 'txtLotCode') { isSelected('txtLotCode', 'selMachineID'); } } } else { isSelected('txtLotCode', 'selMachineID'); } //////////////////////////////////////////////////////////////////////////////////////// } if (document.getElementById('notice')!== null) { document.getElementsByTagName('body')[0].removeChild(document.getElementById('notice')) //>> clear the box } } //-------------------------------------------------------------------------------- else if (responsePHP == "notran") { var mensahe1 = "Please return to<br /><span style='font-size:30px;'>Chemical Weighing<br /> or Supervisor</span>"; notify(mensahe1); if (txtElemID_Active.disabled) { txtElemID_Active.disabled = false; } txtElemID_Active.value = ""; txtElemID_Active.focus(); } //-------------------------------------------------------------------------------- else { /* responsePHP == "1" || responsePHP == "B") { do this if tag is used in this terminal if (responsePHP == "1") { result = "Already used Lot ID"; responsePHP = "Already used Lot ID"; notify("Already used Lot ID.<br />Scan again."); } else if (responsePHP == "B") { // result = "Incomplete Transaction Process"; // responsePHP = "Incomplete Transaction Process"; notify("Incomplete Transaction Process.<br />Scan again."); } */ var mensahe1 = "Last Process: <span style='font-size:30px;'> Terminal " + responsePHP + "</span><br /><br />"; var mensahe2 = "Pls. Proceed: <span style='font-size:30px;'> Terminal " + (parseInt(responsePHP) + 1) + "</span>"; notify(mensahe1 + mensahe2); // notify("Incomplete Transaction Process.<br />Scan again."); if (txtElemID_Active.disabled) { txtElemID_Active.disabled = false; } txtElemID_Active.value = ""; txtElemID_Active.focus(); } //-------------------------------------------------------------------------------- } } var txtElemID_Name = txtElemID_Active.id; if (termNo == "4") { var downGrade = document.getElementById('chkDownGrade').checked; var str = txtElemID_Active.value + "&n=" + termNo + "&down=" + downGrade; } else { var str = txtElemID_Active.value + "&n=" + termNo; } if (txtElemID_Name == "txtLotCode") { //alert(txtElemID_Name) var url = "verifyLotId.php?normal=" + str; } if (txtElemID_Name == "txtLotCodeDownGrade") { //alert(txtElemID_Name) var url = "verifyLotId.php?downgrade=" + str; } ajaxRequest.open("GET", url, true); // force i.e. not to cache ajaxRequest.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); //-------------------------------------------------- ajaxRequest.send(null); ajaxTimeOut = window.setTimeout("timeOut('" + txtElemID_Name + "');", 6000); }
  15. Sorry:( On that time I did not test on saving data Thank you
  16. Hi.. I have query for insert then I just want to add condition that after it save it will locate on the previous page: here is my code: $sql = "INSERT INTO receiving_materials (sr_date, sr_number, si_num, s_name, po_num, qty, mat_code, mat_desc, wh_code, bin_loc) VALUES ('$sr_date', '$sr_number', '$si_num', '$s_name', '$po_num', '$qty', '$mat_code', '$mat_desc', '$wh_code', '$bin_loc') ON DUPLICATE KEY UPDATE sr_date = '$sr_date', sr_number = '$sr_number', si_num = '$si_num', s_name = '$s_name', po_num = '$po_num', qty = '$qty', mat_code = '$mat_code', mat_desc = '$mat_desc', wh_code = 'wh_code', bin_loc = '$bin_loc'"; $res_receiving = mysql_query($sql, $con) or die(mysql_error()); Thank you
  17. Is it the solution is header('Location:ReceivingMaterials.php'); after my query of saving data? Thank you
  18. Hi..thank you for your codes it works but I have a problem. First my php file is ReceivingMaterials.php and it did file your code is work. <?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"; $sql = "SELECT sr_number FROM receiving_materials 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_number'],0,3)); $currentSRYear = (int)(substr($row['sr_number'],2,2)); $currentSRMonth = (int)(substr($row['sr_number'],0,2)); $currentSRNum = (int)(substr($row['sr_number'],6,4)); // $currentSRYear = (int)substr($row['sr_num'],0,2); // $currentSRMonth = (int)substr($row['sr_num'],2,2); // $currentSRDay = (int)substr($row['sr_num'],4,2); // $currentSRNum = (int)substr($row['sr_num'],6,3); $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; } */ $currentSRYMD = substr($row['sr_number'], 0, 6); $currentYMD = date("ymd"); if ($currentYMD > $currentSRYMD) { $currentSRNum = 1; } else { $currentSRNum += 1; } } //------------------------------------------------------------------------------------------------------------------ $yearMonth = date('ymd'); $currentSR = $currentYMD . sprintf("%04d", $currentSRNum); // $currentSR = $yearMonth . sprintf("%04d", $currentSRNum); ?> <html> <title>Stock Requisition</title> <head> <style type="text/css"> #ddcolortabs{ margin-left: 2px; padding: 0; width: 100%; background: transparent; voice-family: "\"}\""; voice-family: inherit; padding-left: 2px; } #ddcolortabs ul{ font: bold 12px Arial, Verdana, sans-serif; margin:0; padding:0; list-style:none; } #ddcolortabs li{ display:inline; margin:0 2px 0 0; padding:0; text-transform:uppercase; } #ddcolortabs a{ float:left; color: white; background: #8cb85c url(layout_image/color_tabs_left.gif) no-repeat left top; margin:2px 2px 0 0; padding:0px 0 1px 3px; text-decoration:none; letter-spacing: 1px; } #ddcolortabs a span{ float:right; display:block; /*background: transparent url(layout_image/color_tabs_right.gif) no-repeat right top;*/ padding:6px 9px 2px 6px; } #ddcolortabs a span{ float:none; } #ddcolortabs a:hover{ background-color: #678b3f; } #ddcolortabs a:hover span{ background-color: #678b3f ; } #ddcolortabs #current a, #ddcolortabs #current span{ /*currently selected tab*/ background-color: #678b3f; } </style> <style> #SR_date{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .9em; margin-left: 10px; width: auto; height: auto; float: left; top : 10px; } #SR_number{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .9em; margin-left: 410px; top : 10px; } table { margin: 10px; font-family: Arial, Helvetica, sans-serif; font-size: .9em; border: 1px solid #DDD; } th { font-family: Arial, Helvetica, sans-serif; font-size: .7em; background: #694; color: #FFF; padding: 2px 6px; border-collapse: separate; border: 1px solid #000; } td { font-family: Arial, Helvetica, sans-serif; font-size: .7em; border: 1px solid #DDD; text-align: left; } #RequestedBy{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 10px; width: auto; height: auto; float: left; top : 10px; } #ApprovedBy{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 15px; width: auto; height: auto; float: left; top : 10px; } #ReceivedBy{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 15px; width: auto; height: auto; float: left; top : 10px; } #SI_number{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .9em; margin-left: 10px; width: auto; height: auto; float: left; top : 20px; } .LLabelRM { display: block; float: left; width: 7em; margin-right: 10px; } .LLabelSecRM { display: block; float: left; width: 7.7em; margin-left : 0px; } .LFieldRM { float: left; margin-right: 595px; } .LFieldSecRM { float: left; margin-right: 15px; } .LFieldSec1RM { float: left; margin-right: 350px; } #save_btn { position: relative; top: 25px; margin-left: 7px; } </style> <script type="text/javascript"> function save_rm(){ var sr_date = document.getElementById("sr_date").value; var sr_number = document.getElementById("sr_number").value; var si_num = document.getElementById("si_num").value; var s_name = document.getElementById("s_name").value; var po_num = document.getElementById("po_num").value; var qty = document.getElementById("qty").value; var mat_code = document.getElementById("mat_code").value; var mat_desc = document.getElementById("mat_desc").value; var wh_code = document.getElementById("wh_code").value; var bin_loc = document.getElementById("bin_loc").value; document.receiving_form.action="ReceivingMaterialsSave.php?sr_date="+sr_date+"&sr_number="+sr_number+"&si_num="+si_num+ "&s_name="+s_name+"&po_num="+po_num+"&qty="+qty+"&mat_code="+mat_code+"&mat_desc="+mat_desc+"&wh_code="+wh_code+ "&bin_loc="+bin_loc; document.receiving_form.submit(); } </script> </head> <body> <form name="receiving_form"> <div id="ddcolortabs"> <ul> <li> <a href="ParameterSettings.php" title="Parameter Settings"><span>Parameter Settings</span></a></li> <li id="current"><a href="ReceivingMaterials.php" title="Receiving Materials"><span>Receiving Materials</span></a></li> <li><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" style="border: none;"> </div> <div id="SR_number"> <label>RM# :</label> <input type="text" name="sr_number" value="<?php echo $currentSR; ?>" size="9" readonly="readonly" style="font-weight: bold; border: none;"> </div> <div id="SI_number"> <label class="LLabelRM">SI/DR# :</label> <input type="text" name="si_num" id="si_num" class="LFieldRM" value="" size="25"> <label class="LLabelRM">Supplier Name :</label> <input type="text" name="s_name" id="s_name" class="LFieldRM" value="" size="25"> <label class="LLabelSecRM">PO # :</label> <input type="text" name="po_num" id="po_num" class="LFieldSecRM" value="" size="25"> <label class="LLabelSecRM">Quantity :</label> <input type="text" name="qty" id="qty" class="LFieldSec1RM" value="" size="25"> <label class="LLabelSecRM">Material Code :</label> <input type="text" name="mat_code" id="mat_code" class="LFieldSecRM" value="" size="25"> <label class="LLabelSecRM">Material Desc. :</label> <input type="text" name="mat_desc" id="mat_desc" class="LFieldSec1RM" value="" size="25"> <label class="LLabelSecRM">WH Code :</label> <input type="text" name="wh_code" id="wh_code" class="LFieldSecRM" value="" size="25"> <label class="LLabelSecRM">BIN Location :</label> <input type="text" name="bin_loc" id="bin_loc" class="LFieldSec1RM" value="" size="25"> </div> <div id="save_btn"> <input type="button" name="save" value="save" onclick="save_rm()"> </div> </form> </body> </html> and after I click save button: it will go to ReceivingMaterialsSave.php <?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"; $sql = "SELECT sr_number FROM receiving_materials 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_number'],0,3)); $currentSRYear = (int)(substr($row['sr_number'],2,2)); $currentSRMonth = (int)(substr($row['sr_number'],0,2)); $currentSRNum = (int)(substr($row['sr_number'],6,4)); // $currentSRYear = (int)substr($row['sr_num'],0,2); // $currentSRMonth = (int)substr($row['sr_num'],2,2); // $currentSRDay = (int)substr($row['sr_num'],4,2); // $currentSRNum = (int)substr($row['sr_num'],6,3); $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; } */ $currentSRYMD = substr($row['sr_number'], 0, 6); $currentYMD = date("ymd"); if ($currentYMD > $currentSRYMD) { $currentSRNum = 1; } else { $currentSRNum += 1; } } //------------------------------------------------------------------------------------------------------------------ $yearMonth = date('ymd'); $currentSR = $currentYMD . sprintf("%04d", $currentSRNum); // $currentSR = $yearMonth . sprintf("%04d", $currentSRNum); $sr_date = $_GET['sr_date']; $sr_number = $_GET['sr_number']; $si_num = $_GET['si_num']; $s_name = $_GET['s_name']; $po_num = $_GET['po_num']; $qty = $_GET['qty']; $mat_code = $_GET['mat_code']; $mat_desc = $_GET['mat_desc']; $wh_code = $_GET['wh_code']; $bin_loc = $_GET['bin_loc']; ?> <html> <title>Stock Requisition</title> <head> <style type="text/css"> #ddcolortabs{ margin-left: 2px; padding: 0; width: 100%; background: transparent; voice-family: "\"}\""; voice-family: inherit; padding-left: 2px; } #ddcolortabs ul{ font: bold 12px Arial, Verdana, sans-serif; margin:0; padding:0; list-style:none; } #ddcolortabs li{ display:inline; margin:0 2px 0 0; padding:0; text-transform:uppercase; } #ddcolortabs a{ float:left; color: white; background: #8cb85c url(layout_image/color_tabs_left.gif) no-repeat left top; margin:2px 2px 0 0; padding:0px 0 1px 3px; text-decoration:none; letter-spacing: 1px; } #ddcolortabs a span{ float:right; display:block; /*background: transparent url(layout_image/color_tabs_right.gif) no-repeat right top;*/ padding:6px 9px 2px 6px; } #ddcolortabs a span{ float:none; } #ddcolortabs a:hover{ background-color: #678b3f; } #ddcolortabs a:hover span{ background-color: #678b3f ; } #ddcolortabs #current a, #ddcolortabs #current span{ /*currently selected tab*/ background-color: #678b3f; } </style> <style> #SR_date{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .9em; margin-left: 10px; width: auto; height: auto; float: left; top : 10px; } #SR_number{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .9em; margin-left: 410px; top : 10px; } table { margin: 10px; font-family: Arial, Helvetica, sans-serif; font-size: .9em; border: 1px solid #DDD; } th { font-family: Arial, Helvetica, sans-serif; font-size: .7em; background: #694; color: #FFF; padding: 2px 6px; border-collapse: separate; border: 1px solid #000; } td { font-family: Arial, Helvetica, sans-serif; font-size: .7em; border: 1px solid #DDD; text-align: left; } #RequestedBy{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 10px; width: auto; height: auto; float: left; top : 10px; } #ApprovedBy{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 15px; width: auto; height: auto; float: left; top : 10px; } #ReceivedBy{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 15px; width: auto; height: auto; float: left; top : 10px; } #SI_number{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .9em; margin-left: 10px; width: auto; height: auto; float: left; top : 20px; } .LLabelRM { display: block; float: left; width: 7em; margin-right: 10px; } .LLabelSecRM { display: block; float: left; width: 7.7em; margin-left : 0px; } .LFieldRM { float: left; margin-right: 595px; } .LFieldSecRM { float: left; margin-right: 15px; } .LFieldSec1RM { float: left; margin-right: 350px; } #save_btn { position: relative; top: 25px; margin-left: 7px; } </style> <script type="text/javascript"> function save_rm(){ var sr_date = document.getElementById("sr_date").value; var sr_number = document.getElementById("sr_number").value; var si_num = document.getElementById("si_num").value; var s_name = document.getElementById("s_name").value; var po_num = document.getElementById("po_num").value; var qty = document.getElementById("qty").value; var mat_code = document.getElementById("mat_code").value; var mat_desc = document.getElementById("mat_desc").value; var wh_code = document.getElementById("wh_code").value; var bin_loc = document.getElementById("bin_loc").value; document.receiving_form.action="ReceivingMaterialsSave.php?sr_date="+sr_date+"&sr_number="+sr_number+"&si_num="+si_num+ "&s_name="+s_name+"&po_num="+po_num+"&qty="+qty+"&mat_code="+mat_code+"&mat_desc="+mat_desc+"&wh_code="+wh_code+ "&bin_loc="+bin_loc; document.receiving_form.submit(); } </script> </head> <body> <form name="receiving_form"> <div id="ddcolortabs"> <ul> <li> <a href="ParameterSettings.php" title="Parameter Settings"><span>Parameter Settings</span></a></li> <li id="current"><a href="ReceivingMaterials.php" title="Receiving Materials"><span>Receiving Materials</span></a></li> <li><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" style="border: none;"> </div> <div id="SR_number"> <label>RM# :</label> <input type="text" name="sr_number" value="<?php echo $currentSR; ?>" size="9" readonly="readonly" style="font-weight: bold; border: none;"> </div> <div id="SI_number"> <label class="LLabelRM">SI/DR# :</label> <input type="text" name="si_num" id="si_num" class="LFieldRM" value="" size="25"> <label class="LLabelRM">Supplier Name :</label> <input type="text" name="s_name" id="s_name" class="LFieldRM" value="" size="25"> <label class="LLabelSecRM">PO # :</label> <input type="text" name="po_num" id="po_num" class="LFieldSecRM" value="" size="25"> <label class="LLabelSecRM">Quantity :</label> <input type="text" name="qty" id="qty" class="LFieldSec1RM" value="" size="25"> <label class="LLabelSecRM">Material Code :</label> <input type="text" name="mat_code" id="mat_code" class="LFieldSecRM" value="" size="25"> <label class="LLabelSecRM">Material Desc. :</label> <input type="text" name="mat_desc" id="mat_desc" class="LFieldSec1RM" value="" size="25"> <label class="LLabelSecRM">WH Code :</label> <input type="text" name="wh_code" id="wh_code" class="LFieldSecRM" value="" size="25"> <label class="LLabelSecRM">BIN Location :</label> <input type="text" name="bin_loc" id="bin_loc" class="LFieldSec1RM" value="" size="25"> </div> <div id="save_btn"> <input type="button" name="save" value="save" onclick="save_rm()"> </div> </form> </body> </html> <?php /* $sql = "INSERT INTO receiving_materials (sr_date, sr_number, si_num, s_name, po_num, qty, mat_code, mat_desc, wh_code, bin_loc) VALUES ('$sr_date', '$sr_number', '$si_num', '$s_name', '$po_num', '$qty', '$mat_code', '$mat_desc', '$wh_code', '$bin_loc') ON DUPLICATE KEY UPDATE sr_date = '$sr_date', sr_number = '$sr_number', si_num = '$si_num', s_name = '$s_name', po_num = '$po_num', qty = '$qty', mat_code = '$mat_code', mat_desc = '$mat_desc', wh_code = 'wh_code', bin_loc = '$bin_loc' WHERE sr_number = '$sr_number' ORDER BY sr_number"; */ $sql = "INSERT INTO receiving_materials (sr_date, sr_number, si_num, s_name, po_num, qty, mat_code, mat_desc, wh_code, bin_loc) VALUES ('$sr_date', '$sr_number', '$si_num', '$s_name', '$po_num', '$qty', '$mat_code', '$mat_desc', '$wh_code', '$bin_loc') ON DUPLICATE KEY UPDATE sr_date = '$sr_date', sr_number = '$sr_number', si_num = '$si_num', s_name = '$s_name', po_num = '$po_num', qty = '$qty', mat_code = '$mat_code', mat_desc = '$mat_desc', wh_code = 'wh_code', bin_loc = '$bin_loc'"; $res_receiving = mysql_query($sql, $con) or die(mysql_error()); ?> After it save in database the SR Number still the SR Number that the previous save for example the previous SR number that I save is 1203300006 Thank you
  19. I want to happen is the sr number will be increment for example today date is: 120330 and I add 0001 which will increment everytime I save data. Example SR Number format: 1203300001 1203300002 1203300003 1203300004 1203300005 1203300006 this example means that I save SR six times for this day and tomorow the SR would be: 1203310001 Thank you
  20. Hi.. I have code for auto generate but I got encountered problem that the SR number did not generate they still 120330001 even though I already save that SR number in my database. I want to happen is after I click the save button the SR number will be 120330002. 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); $sr_date =date('Y-m-d H:i:s'); $sql = "SELECT sr_number FROM receiving_materials 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("%04d", $currentSRNum); $sr_date = $_GET['sr_date']; $sr_number = $_GET['sr_number']; $si_num = $_GET['si_num']; $s_name = $_GET['s_name']; $po_num = $_GET['po_num']; $qty = $_GET['qty']; $mat_code = $_GET['mat_code']; $mat_desc = $_GET['mat_desc']; $wh_code = $_GET['wh_code']; $bin_loc = $_GET['bin_loc']; ?> <html> <title>Stock Requisition</title> <head> <style type="text/css"> #ddcolortabs{ margin-left: 2px; padding: 0; width: 100%; background: transparent; voice-family: "\"}\""; voice-family: inherit; padding-left: 2px; } #ddcolortabs ul{ font: bold 12px Arial, Verdana, sans-serif; margin:0; padding:0; list-style:none; } #ddcolortabs li{ display:inline; margin:0 2px 0 0; padding:0; text-transform:uppercase; } #ddcolortabs a{ float:left; color: white; background: #8cb85c url(layout_image/color_tabs_left.gif) no-repeat left top; margin:2px 2px 0 0; padding:0px 0 1px 3px; text-decoration:none; letter-spacing: 1px; } #ddcolortabs a span{ float:right; display:block; /*background: transparent url(layout_image/color_tabs_right.gif) no-repeat right top;*/ padding:6px 9px 2px 6px; } #ddcolortabs a span{ float:none; } #ddcolortabs a:hover{ background-color: #678b3f; } #ddcolortabs a:hover span{ background-color: #678b3f ; } #ddcolortabs #current a, #ddcolortabs #current span{ /*currently selected tab*/ background-color: #678b3f; } </style> <style> #SR_date{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .9em; margin-left: 10px; width: auto; height: auto; float: left; top : 10px; } #SR_number{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .9em; margin-left: 410px; top : 10px; } table { margin: 10px; font-family: Arial, Helvetica, sans-serif; font-size: .9em; border: 1px solid #DDD; } th { font-family: Arial, Helvetica, sans-serif; font-size: .7em; background: #694; color: #FFF; padding: 2px 6px; border-collapse: separate; border: 1px solid #000; } td { font-family: Arial, Helvetica, sans-serif; font-size: .7em; border: 1px solid #DDD; text-align: left; } #RequestedBy{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 10px; width: auto; height: auto; float: left; top : 10px; } #ApprovedBy{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 15px; width: auto; height: auto; float: left; top : 10px; } #ReceivedBy{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .8em; margin-left: 15px; width: auto; height: auto; float: left; top : 10px; } #SI_number{ position: relative; font-family: Arial, Helvetica, sans-serif; font-size: .9em; margin-left: 10px; width: auto; height: auto; float: left; top : 20px; } .LLabelRM { display: block; float: left; width: 7em; margin-right: 10px; } .LLabelSecRM { display: block; float: left; width: 7.7em; margin-left : 0px; } .LFieldRM { float: left; margin-right: 595px; } .LFieldSecRM { float: left; margin-right: 15px; } .LFieldSec1RM { float: left; margin-right: 350px; } #save_btn { position: relative; top: 25px; margin-left: 7px; } </style> <script type="text/javascript"> function save_rm(){ var sr_date = document.getElementById("sr_date").value; var sr_number = document.getElementById("sr_number").value; var si_num = document.getElementById("si_num").value; var s_name = document.getElementById("s_name").value; var po_num = document.getElementById("po_num").value; var qty = document.getElementById("qty").value; var mat_code = document.getElementById("mat_code").value; var mat_desc = document.getElementById("mat_desc").value; var wh_code = document.getElementById("wh_code").value; var bin_loc = document.getElementById("bin_loc").value; document.receiving_form.action="ReceivingMaterialsSave.php?sr_date="+sr_date+"&sr_number="+sr_number+"&si_num="+si_num+ "&s_name="+s_name+"&po_num="+po_num+"&qty="+qty+"&mat_code="+mat_code+"&mat_desc="+mat_desc+"&wh_code="+wh_code+ "&bin_loc="+bin_loc; document.receiving_form.submit(); } </script> </head> <body> <form name="receiving_form"> <div id="ddcolortabs"> <ul> <li> <a href="ParameterSettings.php" title="Parameter Settings"><span>Parameter Settings</span></a></li> <li id="current"><a href="ReceivingMaterials.php" title="Receiving Materials"><span>Receiving Materials</span></a></li> <li><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" style="border: none;"> </div> <div id="SR_number"> <label>RM# :</label> <input type="text" name="sr_number" value="<?php echo $currentSR; ?>" size="9" readonly="readonly" style="font-weight: bold; border: none;"> </div> <div id="SI_number"> <label class="LLabelRM">SI/DR# :</label> <input type="text" name="si_num" id="si_num" class="LFieldRM" value="" size="25"> <label class="LLabelRM">Supplier Name :</label> <input type="text" name="s_name" id="s_name" class="LFieldRM" value="" size="25"> <label class="LLabelSecRM">PO # :</label> <input type="text" name="po_num" id="po_num" class="LFieldSecRM" value="" size="25"> <label class="LLabelSecRM">Quantity :</label> <input type="text" name="qty" id="qty" class="LFieldSec1RM" value="" size="25"> <label class="LLabelSecRM">Material Code :</label> <input type="text" name="mat_code" id="mat_code" class="LFieldSecRM" value="" size="25"> <label class="LLabelSecRM">Material Desc. :</label> <input type="text" name="mat_desc" id="mat_desc" class="LFieldSec1RM" value="" size="25"> <label class="LLabelSecRM">WH Code :</label> <input type="text" name="wh_code" id="wh_code" class="LFieldSecRM" value="" size="25"> <label class="LLabelSecRM">BIN Location :</label> <input type="text" name="bin_loc" id="bin_loc" class="LFieldSec1RM" value="" size="25"> </div> <div id="save_btn"> <input type="button" name="save" value="save" onclick="save_rm()"> </div> </form> </body> </html> <?php $sql = "INSERT INTO receiving_materials (sr_date, sr_number, si_num, s_name, po_num, qty, mat_code, mat_desc, wh_code, bin_loc) VALUES ('$sr_date', '$sr_number', '$si_num', '$s_name', '$po_num', '$qty', '$mat_code', '$mat_desc', '$wh_code', '$bin_loc') ON DUPLICATE KEY UPDATE sr_date = '$sr_date', sr_number = '$sr_number', si_num = '$si_num', s_name = '$s_name', po_num = '$po_num', qty = '$qty', mat_code = '$mat_code', mat_desc = '$mat_desc', wh_code = 'wh_code', bin_loc = '$bin_loc'"; $res_receiving = mysql_query($sql, $con) or die(mysql_error()); ?> any help is highly appreciated. Thank you
  21. Hi.. I need help in concatenation. here is my code: SELECT (SUM(TIMESTAMPDIFF(DAY, chemicalweighing_dateEntry, NOW()))), (SUM(TIMESTAMPDIFF(HOUR, chemicalweighing_dateEntry, NOW()))) - (SUM(TIMESTAMPDIFF(DAY,chemicalweighing_dateEntry, NOW())) * 24) AS age_day FROM kanban_data; the output of this is: 57 204 they are separated in between two columns. I want to combine them in one column like this: 57 day(s) 204 hr(s) ago Thank you
  22. I tried this: SELECT(concat(SUM(TIMESTAMPDIFF(DAY, chemicalweighing_dateEntry, NOW())),' day(s) '), SUM(TIMESTAMPDIFF(HOUR, chemicalweighing_dateEntry, NOW()) - (TIMESTAMPDIFF(DAY, chemicalweighing_dateEntry, NOW()) * 24), ' hr(s) ago')) AS AGE FROM kanban_data; and I got an error: Error Code : 1241 Operand should contain 1 column(s) (0 ms taken) I can't figured out where I am wrong Thank you
  23. I revised my code to this: SELECT (concat(TIMESTAMPDIFF(DAY, AVG(chemicalweighing_dateEntry), NOW()),' day(s) ', TIMESTAMPDIFF(HOUR, AVG(chemicalweighing_dateEntry), NOW()) - (TIMESTAMPDIFF(DAY, AVG(chemicalweighing_dateEntry), NOW()) * 24), ' hr(s) ago')) AS AGE FROM kanban_data GROUP BY chemicalweighing_dateEntry; and i also try instead of AVG I use MAX SELECT (concat(TIMESTAMPDIFF(DAY, MAX(chemicalweighing_dateEntry), NOW()),' day(s) ', TIMESTAMPDIFF(HOUR, MAX(chemicalweighing_dateEntry), NOW()) - (TIMESTAMPDIFF(DAY, MAX(chemicalweighing_dateEntry), NOW()) * 24), ' hr(s) ago')) AS AGE FROM kanban_data GROUP BY chemicalweighing_dateEntry; and they are same output. and I attach the result. Now I want to know how can I can the sum of ALL this data. I need a query again to get the sum or I need output is : 67 day(s) 200 hr(s) ago. Thank you so much
  24. I just want to get is the aging of all dateentry in chemicalweighing. Thank you
×
×
  • 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.