Jump to content

FooKelvin

Members
  • Posts

    138
  • Joined

  • Last visited

Everything posted by FooKelvin

  1. Hi, how to generate auto increment ID with combination of characters and number. For example, i would like to have product ID start from PROD00001. When i add second product, the ID will check on the existing database to check PROD00001 is the latest ID. So, the second product ID will +1, become PROD00002.
  2. Hi All, i would like to create a web page that allow user to feedback. So, i need a page where allow admin to setup a survey form. The more flexible, the best. What i mean is, admin able to create a form. A form may contain of check box, Main question, Sub Question and also open text feed back. For now, i able to complete only one module, which is allow admin add only Main Question, i have stuck with the Sub Questions. Here is my sample codes. HTML Page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Test Market</title> <script src="http://jtable.org/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script> <script src="http://jtable.org/Scripts/jquery-ui-1.10.0.min.js" type="text/javascript"></script> </head> <script type="text/javascript"> $(document).ready(function () { var max_fields = 10; //maximum input boxes allowed var wrapper = $(".input_fields_wrap"); //Fields wrapper var add_button = $(".add_field_button"); //Add button ID var x = 1; //initlal text box count $(add_button).click(function (e) { //on add input button click e.preventDefault(); if (x = x) { //max input box allowed x++; //text box increment $(wrapper).append('<div><input type="text" name="question[]"/><a href="#" class="remove_field">Remove</a></div>'); //add input box } }); $(wrapper).on("click", ".remove_field", function (e) { //user click on remove text e.preventDefault(); $(this).parent('div').remove(); x--; }) }); </script> <style> #b-wrapper{ width: 297px; margin: 0 auto; } </style> <body> <div id="b-wrapper"> <form action="save-form.php?mod=add" method="post"> <table> <tr> <td><lable>Form Name</lable></td> <td><input name="form_name"></input></td> </tr> <tr> <td><lable>Form Description</lable></td> <td><input name="form_desc"></input></td> </tr> </table> <div class="input_fields_wrap"> <div>Question</div> <div><input type="text" name="question[]"></input></div> </div> <button class="add_field_button">Add More Fields</button> <input type="submit"></input> </form> </div> </body> </html> SUBMIT FORM PAGE: <?php $serverName = "server_one"; //serverName\instanceName $connectionInfo = array("Database" => "RSA", "UID" => "username", "PWD" => "password"); $conn = sqlsrv_connect($serverName, $connectionInfo); $formName = $_POST['form_name']; $formDesc = $_POST['form_desc']; $formQuestion = $_POST['question']; $id = $_POST["id"]; foreach( $formQuestion as $key => $text_field ) { //print "$formQuetion"; echo '<br>'; //MySqli Insert Query $result = "INSERT INTO form(form_name,form_description,question) VALUES('$formName','$formDesc','$text_field')"; $stmt = sqlsrv_query($conn, $result); } ?> This only able to dynamically add main question, how if there is a sub question? radio button? selection? check box?
  3. Still the same problem, the file name auto change to download.xls. Help~~~
  4. Hi Josh, The name: is for excel sheet name. I would like to change the file name, for example myname.xls Thank You
  5. Hi Guys, I am using this plugin to export my table to excel file. But anyone know how to have custom name for the excel file? If possible the excel file name should follow the web html title. <title>Name</title> Link: Export to Excel Plug in
  6. wow~ another new thing to learn..thank you
  7. Hi Barand, I Found a solution. if ($sd) $data[$cid]['events'][$m][] = date_format(($sd), 'd/m/y'); Thank You
  8. Hi Guys. i Found a solution. Thank You so Much!
  9. Hi, Anyone know about sqlsvr date format? Can link to this post for more details, thank you http://forums.phpfreaks.com/topic/298039-php-course-event-monthly-view/?do=findComment&comment=1520531
  10. Hi Barand, It's working now. The date display in the correct months in my database, but the format is incorrect.
  11. Sorry, should be $newarray = array(11 => array(),12 => array(),1 => array(),2 => array(),3 => array(),4 => array(),5 => array(),6 => array(),7 => array(),8 => array(),9 => array(),10 => array()); print_r ($newarray); $data = array(); $trows = ''; Am i Right?
  12. Is that what you mean? $newarray = array(11 => "",12 => "",1 => "",2 => "",3 => "",4 => "",5 => "",6 => "",7 => "",8 => "",9 => "",10 => ""); print_r ($newarray); $data = array(); $trows = ''; and the output is:
  13. Oh, there is error on the select statement. after i fixed it, the error gone, the page show nothing. When i remove the $newarray = [11=>[],12=>[],1=>[],2=>[],3=>[],4=>[],5=>[],6=>[],7=>[],8=>[],9=>[],10=>[]]; $data = []; $trows = ''; the output show me,the table body without data.
  14. Hi Barand, I not sure what is the problem, the page show nothing. $sql = "SELECT SELECT c.cid, c.courseName, e.startDate, MONTH(e.startDate) as month FROM course c LEFT JOIN evtTable e ON c.cid=e.cid ORDER BY cid,startDate"; $stmt = sqlsrv_query($conn, $sql); while (list($cid, $cn, $sd, $m) = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC)) { if (!isset($data[$cid])) { $data[$cid]['name'] = $cn; $data[$cid]['events'] = $newarray; } if ($sd) $data[$cid]['events'][$m][] = date('j/m/Y', strtotime($sd)); } /********************************************************** * create table from array data ***********************************************************/ foreach ($data as $cid=>$cdata) { $trows .= "<tr><td>$cid</td><td class='cn'>{$cdata['name']}</td>"; foreach ($cdata['events'] as $dates) { $trows .= "<td class='dt'>" . join('<br>', $dates) . "</td>"; } $trows .= "</tr>\n"; } I change the "USING" statement to "ON" statement, because i get "Incorrect syntax near 'USING'." error message. And i try to change mysql to sqlsrv. Maybe i have change something wrong. please help..
  15. Hi Barand, is that mean, i need to create another table to store, months? e.g: January, February........December The event table did have the date, but there is a possibility to have no event in that month.
  16. Hello, How to show the table in PHP application? I have 2 database here: Coursetbl (Consist of all the course) Eventtbl (Consist of only course that already happen or planning) So the sample data in Course is this: +---------------------------------+ |cid |courseName |courseSize-| |---------------------------------| |c01 |Microsoft Excel| 20 | |---------------------------------+ |c02 | PHP | 20 | |---------------------------------+ |c03 |Microsoft Word | 20 | |---------------------------------+ |c04 | CSS | 20 | |---------------------------------+ |c05 | ASP .NET | 20 | |---------------------------------+ |c06 | JavaScript | 20 | |---------------------------------+ |c07 | Buz Writing | 20 | |---------------------------------+ Here is the sample data for Eventtbl data: +-----+---------------+-----------+-----------+----------------------- |eid |courseName |StartDate |EndDate |Remarks | |---------------------------------+-----------+----------------------+ |e01 |Microsoft Excel|2015-01-02 |2015-01-05 |Request extra material| |---------------------------------+-----------+----------------------+ |e02 |Microsoft Excel|2015-01-09 |2015-01-10 |NULL | |---------------------------------+-----------+----------------------+ |e03 |Microsoft Word |2015-01-10 |2015-01-15 |Request extra food | |---------------------------------+-----------+----------------------+ |e04 | CSS |2015-04-21 |2015-04-25 |NULL | |---------------------------------+-----------+----------------------+ |e06 | Buz Writing |2015-05-20 |2015-05-21 |Request extra drinks | |---------------------------------+-----------+---------------------- |e07 |Microsoft Excel|2015-05-20 |2015-05-23 |NULL | |---------------------------------+-----------+----------------------+ |e08 | Buz Writing |2015-05-22 |2015-05-25 |Request extra trainer | |---------------------------------+-----------+----------------------+ The course table include all the course, and the event table course will appear when there is an event, and most of them are repeated. So the output that i plan to do is, have a look the attachment. For your info : Nov-Jan = Q1 Feb-Apr = Q2 May-July = Q3 Aug-Oct = Q4 The Report Show Fiscal Year 2015 Report. If the event didn't happen, the column show empty, if the event is happen, then the column is show the start date. If there is a same event happen in a months, the date should listed down.
  17. Hello, I have stuck in here. Let me explain the background. Each Fiscal Year have Q1 until Q4. Each Quarter have different type form name. In a quarter may have more than 4 forms. So, each form is to track the points that the participant earn. One form allow more than one participant. One participant can participate in multiple form. So each participant have a total marks for each form. Please Have A Look The Attachment. Right now, I need to design a report to show Top 20 highest score participant. It can be cumulative from Q1 + Q2 + Q3 + Q4. Mean that, for example:- In This case. The data is less, so i highlighted Top 3 highest score. +---------------+ |Bill | 41 | |Aaron | 36 | |Gates | 27 | +---------------+ To produce this filter, the only way i can think off is to sum all the data in a database by name?? is that a good way? or is there any better way? Thank You
  18. Hi scootstah, It's working. Thank You. Thanks everyone =)
  19. this console.log shows: [{"qstartDate":"2/1/2015","qendDate":"4/30/2015","label":"Q2"}]
  20. Hi scootstah, i tried but nothing appear in #qstartDate value. i try to change to console for more details. like this, success: function (data) { a = (data[0].qstartDate); console.log(a) $("#qendDate").val(data[0].qendDate); } the console.log return "undefined"
  21. Hi requinix, i have two pages. select.asp and source.asp select.asp contain of 3 field. on of the field is drop down list. so, when user select the drop down, it trigger ajax "url: "source.asp?term=" + quarter". so the page of source.asp?term="+quarter" display: [{qstartDate: "2/1/2015", qendDate: "4/30/2015", label: "Q2"} 0: {qstartDate: "2/1/2015", qendDate: "4/30/2015", label: "Q2"} label: "Q2" qendDate: "4/30/2015" qstartDate: "2/1/2015" I need to take the "qendDate" value and "qstartDate" value.
  22. Hi i have stuck with the ajax return success. Firstly let me explain what i going to do. i have a input form, the form have 3 field text. 1) start Date 2) end Date 3) quarter the "quarter" field is a drop down list. i have a database to store the date of period of Q1,Q2,Q3,Q4. so i want to have, when a user select a drop down, the date will return the Q1 Period. For now, i'am able to return the result like this: [{"qstartDate":"11/1/2014","qendDate":"1/31/2014"}] But, when i wanted to return the date into my form, it fail. So, Here is my Code $("#slc-quarter").change(function () { var quarter = $(this).val(); $.ajax({ url: "searchQuarterDetails.asp?term=" + quarter, success: function (data) { var a = qstartDate; alert(a) } //$("#qstartDate").val(ui.item.qstartDate); //$("#qendDate").val(ui.item.qendDate); }) }) The result that i get from this code after i change the drop down menu is: [object htmlinputelement]
  23. Hi Barand, i think my explanation not clear enough. Instead of left to right to get total, it's top to bottom.
  24. Opps, sorry for that. The problem are real. I have 2 sets of problem, maybe i should create a new post new ask different question? i'm really sorry =(
×
×
  • 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.