Jump to content

FooKelvin

Members
  • Content count

    138
  • Joined

  • Last visited

Community Reputation

0 Neutral

About FooKelvin

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling
  1. I would like to have this +3 apply when the paymentterm if is less than 45. So the current code is using case statement. SELECT SUM(sblPOAmount) AS totalPOAmt, case when paymentTerm = '45 Days' then DATENAME(Day, DATEADD(day, SUBSTRING(paymentTerm, 1, 2) + 3, SBLInvoiceDate)) else DATENAME(Day, DATEADD(day, SUBSTRING(paymentTerm, 1, 2) + 0, SBLInvoiceDate)) end FROM [A_Sys].[dbo].[Eventtbl] WHERE DATENAME(MONTH, DATEADD(day,SUBSTRING(paymentTerm, 1, 2)+3,SBLInvoiceDate))='June' AND DATENAME(YEAR, DATEADD(day,SUBSTRING(paymentTerm, 1, 2)+3,SBLInvoiceDate))='2017' Group By paymentTerm,SBLInvoiceDate The Sum having multiple result due to "Group By", but if i run it without Group By , it will have error message. Please help
  2. Hi All, I have generate a form which contain the id and name. the name and id i use php foreach them from database, to make it simple, im just copy the HTML and paste it here. each of them have individual approval status and remarks. once submit, it should update individual rows. I am using ajax to post. My current code. <html> <body> <hr> <section> <h3 id="title454"> Requestor </h3> </section> <form id="form" action="" method="post"> <table> <tr> <th>Employee Name</th> <th>Employee ID</th> <th>Remark</th> <th>Action</th> </tr> <tr><td>Kelvin</td><td>EE123</td><td><textarea name="remark[]"></textarea></td><td><select name="status[]"><option disabled value="">-Pending-</option><option value="Approved">Approve</option><option value="Reject">Reject</option></select><br></td></tr><tr><td>James</td><td>EE156</td><td><textarea name="remark[]"></textarea></td><td><select name="status[]"><option disabled value="">-Pending-</option><option value="Approved">Approve</option><option value="Reject">Reject</option></select><br></td></tr></table> <hr> <table> <ul> <section> <h3 id="title454"> 1st Level Approval </h3> </section> <li> <label>Amount Approved</label> <span> <select name="amount-approved"> <option disabled value="" selected>-Select-</option> <option>50%</option> <option>100%</option> </select> </span> </li> </ul> </table> <input id="submit" type="button" name="submit" value="submit"> </form> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script> $(document).ready(function(){ // click on button submit $("#submit").on('click', function(){ // send ajax $.ajax({ url: 'tier_one_submit_status.php', // url where to submit the request type : "POST", // type of action POST || GET dataType : 'json', // data type data : $("#form").serialize(), // post data || get data success : function(result) { // you can see the result from the console // tab of the developer tools console.log(result); }, error: function(xhr, resp, text) { console.log(xhr, resp, text); } }) }); }); </script> </body> </html> after click the submit button, i would like to update the data individually. Please help.
  3. FooKelvin

    Foreach no result

    Hi mac, yes...it is similar questions, but due to echo implode('<hr>',$replies[$q_id]); // note: this works correctly if there is a single reply, the result is just the single array element by itself when i export to excel, it automatically merge the table in excel, which is good.. some how i face problem when i Vloopup in excel file, so i am thinking to split them when it has multiple feedback.
  4. FooKelvin

    Foreach no result

    Sorry for the misalignment. Current Output: Database table and expect result: foreach.txt
  5. FooKelvin

    Foreach no result

    I have a questions table and feedback table. I able to foreach the question header but not the feedback. My code as above: <?php $sql2 = "SELECT DISTINCT[question_id],[q_text] FROM [question]"; $ques = array(); $stmt2 = sqlsrv_query($conn, $sql2, $ques); while ($row = sqlsrv_fetch_array($stmt2, SQLSRV_FETCH_ASSOC)) { $ques[$row['question_id']] = $row['q_text']; } $sql = "SELECT [question_id], [Expr3],[Expr2] FROM [feedback] ORDER BY [Expr2] ASC"; $data = array(); $stmt = sqlsrv_query($conn, $sql); while (list($qid, $a, $eid) = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC)) { if (!isset($data[$qid][$eid])) { $data[$qid][$eid] = $newArray2; } $data[$qid][$eid][] = $a; } ?> <div class="container"> <?php // produce table header echo "<table border='1' id='table2excel'>\n"; echo "<tr><th>Employee ID</th>"; // loop over array of questions for the header foreach ($ques as $question) { echo "<th>$question</th>"; } echo "</tr>\n"; foreach ($data as $qid => $question) { foreach ($question as $question => $replies) { echo "<tr><td>$question</td>"; foreach (array_keys($ques) as $q_id) { echo "<td>"; echo $replies[$q_id]; echo "</td>"; } echo "</tr>\n"; echo "</tr>\n"; } } echo "</table>\n"; Questions Table: question_id q_text 1 Do you Like Red Color? 02A Do you Like Yellow Color? 02B Do you Like Blue Color? 3 Do you Like Green Color? 4 What color you like among them? 5 Do you Like Purple Color? 6 Do you Like Gold Color? 7 Do you Like Rose Gold Color? 8 Do you Like Black Color? 9 Do you Like Orange Color? The question 4, might be multiple answer. Feedback Table: question_id Expr2 Expr3 1 EMP1001 Yes 02A EMP1001 No 4 EMP1001 Red 4 EMP1001 Yellow 4 EMP1001 Blue 5 EMP1001 No 6 EMP1001 No 3 EMP1001 Yes 02B EMP1001 Yes 7 EMP1001 Yes 8 EMP1001 Yes 9 EMP1001 Yes 1 EMP1002 Yes 02A EMP1002 No 4 EMP1002 Red 5 EMP1002 No 6 EMP1002 Yes 3 EMP1002 Yes 02B EMP1002 Yes 7 EMP1002 No 8 EMP1002 9 EMP1002 Yes Result: Employee ID Do you Like Red Color? Do you Like Yellow Color? Do you Like Blue Color? Do you Like Green Color? What color you like among them? Do you Like Purple Color? Do you Like Gold Color? Do you Like Rose Gold Color? Do you Like Black Color? Do you Like Orange Color? EMP1001 EMP1002 EMP1001 EMP1002 EMP1001 EMP1002 EMP1001 EMP1002 EMP1001 EMP1002 EMP1001 EMP1002 EMP1001 EMP1002 EMP1001 EMP1002 EMP1001 EMP1002 EMP1001 EMP1002 Expected Result: Employee ID Do you Like Red Color? Do you Like Yellow Color? Do you Like Blue Color? Do you Like Green Color? What color you like among them? Do you Like Purple Color? Do you Like Gold Color? Do you Like Rose Gold Color? Do you Like Black Color? Do you Like Orange Color? EMP1001 Yes No Yes Yes Red No No Yes Yes Yes EMP1001 Yes No Yes Yes Yellow No No Yes Yes Yes EMP1001 Yes No Yes Yes Blue No No Yes Yes Yes EMP1002 Yes No Yes Yes Red No Yes No Yes The question id no.4 will allow multiple choice to select, hence there will be multiple feedback for that particular question. foreach.txt
  6. FooKelvin

    JQuery Control Drop down list

    Hi All, Would like to ask whether can the drop down list in html can be control by Jquery with this condition? Each question can only rate for 3 times, the following drop box for that question should disable and not allow to make any rating. here is my HTML code: <div> <span id="questionnaire-question">Q1)&nbspPlease QuestionA</span> <table> <tr style="width: 365px;"> <td><label>A1</label></td> <td> <select name="ranking[13]" class="02A" group="02A"> <option value="" >Please Rank</option> <option>1</option> <option>2</option> <option>3</option> </select> </td> </tr> <tr style="width: 365px;"> <td><label>A2</label></td> <td> <select name="ranking[14]" class="02A" group="02A"> <option value="" >Please Rank</option> <option>1</option> <option>2</option> <option>3</option> </select> </td> </tr> <tr style="width: 365px;"> <td><label>A3</label></td> <td> <select name="ranking[15]" class="02A" group="02A"> <option value="" >Please Rank</option> <option>1</option> <option>2</option> <option>3</option> </select> </td> </tr> <tr style="width: 365px;"> <td><label>A4</label></td> <td> <select name="ranking[16]" class="02A" group="02A"> <option value="" >Please Rank</option> <option>1</option> <option>2</option> <option>3</option> </select> </td> </tr> </table> </div> <div> <span id="questionnaire-question">Q2)&nbspPlease QuestionB</span> <table> <tr style="width: 365px;"> <td><label>B1</label></td> <td> <select name="ranking[21]" class="03A" group="03A"> <option value="" >Please Rank</option> <option>1</option> <option>2</option> <option>3</option> </select> </td> </tr> <tr style="width: 365px;"> <td><label>B2</label></td> <td> <select name="ranking[22]" class="03A" group="03A"> <option value="" >Please Rank</option> <option>1</option> <option>2</option> <option>3</option> </select> </td> </tr> <tr style="width: 365px;"> <td><label>B3</label></td> <td> <select name="ranking[23]" class="03A" group="03A"> <option value="" >Please Rank</option> <option>1</option> <option>2</option> <option>3</option> </select> </td> </tr> <tr style="width: 365px;"> <td><label>B4</label></td> <td> <select name="ranking[28]" class="03A" group="03A"> <option value="" >Please Rank</option> <option>1</option> <option>2</option> <option>3</option> </select> </td> </tr> </table> </div> Thank You.
  7. FooKelvin

    PHP JSON Encode Date Format

    Thanks! now it successfully convert to timestamp format But yet, the date not able to show up. hmm...let me figure it out..
  8. FooKelvin

    PHP JSON Encode Date Format

    Yup, I tried to put it the php class like this, am i put in a correct place? class JsonDateTime extends DateTime implements JsonSerializable { //<== Getting Red line error "JsonDateTime" public function __construct(DateTime $dt) { parent::__construct($dt->format("r")); } public function jsonSerialize() { return "/Date(" . $this->getTimestamp() . ")/"; } } $result = sqlsrv_query( $conn, "SELECT COUNT(*) AS RecordCount FROM [A_Sys].[dbo].[testdate]"); $row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC); The browser show HTTP ERROR 500
  9. FooKelvin

    PHP JSON Encode Date Format

    $result = sqlsrv_query( $conn, "SELECT COUNT(*) AS RecordCount FROM [A_Sys].[dbo].[testdate]"); $row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC); $recordCount = $row['RecordCount']; //Get records from database $result = "SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY [emp_id]) As Row, * FROM [A_Sys].[dbo].[testdate]) As PeopleWithRowNumbers WHERE Row >" . $_REQUEST["jtStartIndex"] . "AND Row <= " . $_GET['jtStartIndex'] ." + ". $_GET['jtPageSize'].""; $stmt = sqlsrv_query($conn, $result); //Add all records to an array $rows = array(); while($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) { $rows[] = $row; } //$recordCount = $row['RecordCount']; //Return result to jTable $jTableResult = array(); $jTableResult['Result'] = "OK"; $jTableResult['TotalRecordCount'] = $recordCount; $jTableResult['Records'] = $rows; print json_encode($jTableResult); This is my DB: emp_id course1 --------------------------- 1012345 1/5/2017 My Print JSON {"Result":"OK","TotalRecordCount":1,"Records":[{"Row":"1","emp_id":"1012345","course1":{"date":"2017-01-05 00:00:00","timezone_type":3,"timezone":"Asia\/Brunei"}}]}
  10. FooKelvin

    PHP JSON Encode Date Format

    The first sample code is from documentation, the second code sample is my own output.. Here is the link of documentation. the problem that i facing now is the date format. i cant get the exactly the date format in the documentation. which is converted to unix timestamp. Documentation => http://jtable.org/GettingStarted
  11. FooKelvin

    PHP JSON Encode Date Format

    this is my current php code. $rows = array(); while($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) { $rows[] = $row; // <= do you mean i need to convert it here? } //$recordCount = $row['RecordCount']; //Return result to jTable $jTableResult = array(); $jTableResult['Result'] = "OK"; $jTableResult['TotalRecordCount'] = $recordCount; $jTableResult['Records'] = $rows; print json_encode($jTableResult);
  12. FooKelvin

    PHP JSON Encode Date Format

    Hi All, I am using JTable Plug in and using PHP code as my server language. The plug in requires json encode in this format, ** please ignore other data. except for "RecordDate" ** { "Result":"OK", "Records":[ {"PersonId":1,"Name":"Benjamin Button","Age":17,"RecordDate":"\/Date(1320259705710)\/"}, {"PersonId":2,"Name":"Douglas Adams","Age":42,"RecordDate":"\/Date(1320259705710)\/"}, {"PersonId":3,"Name":"Isaac Asimov","Age":26,"RecordDate":"\/Date(1320259705710)\/"}, {"PersonId":4,"Name":"Thomas More","Age":65,"RecordDate":"\/Date(1320259705710)\/"} ] } What i have for my output is, { "Result": "OK", "TotalRecordCount": 1, "Records": [ {"Row": "1","emp_id": "Nhhh","course1": {"date": "2017-01-06 00:00:00","timezone_type": 3,"timezone": "Asia\/Brunei"} }] } Im currently using datetime as my data type in my database (SQL Server), and the output is empty due to wrong json date format. thanks for the help.
  13. FooKelvin

    For Each Loop with their own a href

    Please Ignore it. i manage to make it correct..
  14. FooKelvin

    For Each Loop with their own a href

    This is my array: Array ( [name] => [events] => Array ( [0] =>A.doc [1] =>B.pdf [2] =>C.pdf ) ) when echo it out, there is one extra row in between. like this..
  15. FooKelvin

    For Each Loop with their own a href

    Hi Jacquest1, Im testing your code as well..is working actually..
×

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.