Jump to content

hardikspider123

Members
  • Posts

    27
  • Joined

  • Last visited

Everything posted by hardikspider123

  1. hello, I need last inserted id as a variable in php. I am posting value through ajax in MySQL and getting back last_insert_id in success function as an alert. but can you tell me how would I get in it php or jquery variable? I want to get inserted id back because I want to insert records on last inserted id. Please let me know how it is possible Thanks in advance.
  2. Hi I want to create an application. Main form contain other form(one to many relationship) for example if I insert record for one employee which can have multiple phone numbers.so I should be able to insert multiple phone numbers for one employee. so can you give me hint that how should I create this scenario. I have developed form already but don't know from where start coding. I am new to php,jquery,ajax,html Please guide me. Thanks in advance.
  3. I have 2 dropdown one in table and one is outside table. both has same values. Now my question is that if I select value from dropdown then it should show same value in table dropdown for all rows. Please let me know if you are not getting my question.
  4. --Add 30 Days--> <input id='button3' type='button' class='move' value='Add Days' /> <select id="daycombo1" class="mycombo1"> <option>SELECT</option> <option value="1">1</option> <option value="3">3</option> <option value="7">7</option> <option value="14">14</option> <option value="30">30</option> <option value="40">40</option> <option value="50">50</option> <option value="60">60</option> <option value="70">70</option> <option value="80">80</option> <option value="90">90</option> </select> This is dropdown and I want to enter days in html dropdown for all rows. here is my code for html table <script type="text/javascript"> //function getIt(){ //var i=$("#button3").val() //alert(i); //} $('#button3').click(function() { // $v1 = ($('#daycombo1').val()); // alert($v1); grabVal(); }); function grabVal() { $('.hovertable tbody tr').each(function () { var s = $(this).find('.mycombo input').val(); $('.mycombo1').find('option[value="' + s + '"]'); }) } $('#button1').click(function() { iterate(); }); $(".mycombo").change(function() { ($(this).find("option:selected").text()); }); function iterate() { var values = []; $("input:checkbox").each(function() { var $this = $(this); // console.log($this); var selected = {}; var $v = ""; var counter = 0; if ($this.is(":checked")) { $v = $this.closest("td").siblings("td") if ($v.find("select").attr("class") == "mycombo") { selected["memberid"] = $this.val(); selected['combo'] = $v.find("#combo :selected").text(); selected['daysadded'] = $v.find("#daycombo :selected").text(); } else { } values.push(selected); } else { } counter++; }); var dataArrayFields = {}; // dataArrayFields['command'] = 'forgotemail'; dataArrayFields['params'] = values; var ob = (JSON.stringify(values)); $.ajax({ type: "POST", url: "update3.php", data: {pData: ob}, // success: function(data2) { // whatToDo(data2); // // }, success: function() { alert("Records Updated Suceessfully"); location.reload(true); // $("#load").html(msg); }, cache: false }); } function whatToDo(status) { if (status == "success") { // echo "Record updated succesuufully"; location.reload(true); // // window.location = self; } else { } } $(document).ready(function() { $('.check:button').toggle(function() { $('input:checkbox').attr('checked', 'checked'); $(this).val('Uncheck All') }, function() { $('input:checkbox').removeAttr('checked'); $(this).val('Check All'); }) }) </script>
  5. Yes Html table and yes I am looking to change html tables display based on the selection made in drop down menu. and I want to do it instantly
  6. <script type="text/javascript"> //function getIt(){ //var i=$("#button3").val() //alert(i); //} $('#button3').click(function() { // $v1 = ($('#daycombo1').val()); // alert($v1); grabVal(); }); function grabVal() { $('.hovertable tbody tr').each(function () { var s = $(this).find('.mycombo input').val(); $('.mycombo1').find('option[value="' + s + '"]'); }) } $('#button1').click(function() { iterate(); }); $(".mycombo").change(function() { ($(this).find("option:selected").text()); }); function iterate() { var values = []; $("input:checkbox").each(function() { var $this = $(this); // console.log($this); var selected = {}; var $v = ""; var counter = 0; if ($this.is(":checked")) { $v = $this.closest("td").siblings("td") if ($v.find("select").attr("class") == "mycombo") { selected["memberid"] = $this.val(); selected['combo'] = $v.find("#combo :selected").text(); selected['daysadded'] = $v.find("#daycombo :selected").text(); } else { } values.push(selected); } else { } counter++; }); var dataArrayFields = {}; // dataArrayFields['command'] = 'forgotemail'; dataArrayFields['params'] = values; var ob = (JSON.stringify(values)); $.ajax({ type: "POST", url: "update3.php", data: {pData: ob}, // success: function(data2) { // whatToDo(data2); // // }, success: function() { alert("Records Updated Suceessfully"); location.reload(true); // $("#load").html(msg); }, cache: false }); } function whatToDo(status) { if (status == "success") { // echo "Record updated succesuufully"; location.reload(true); // // window.location = self; } else { } } $(document).ready(function() { $('.check:button').toggle(function() { $('input:checkbox').attr('checked', 'checked'); $(this).val('Uncheck All') }, function() { $('input:checkbox').removeAttr('checked'); $(this).val('Check All'); }) }) </script> above is code for my checkbox table <!--Add 30 Days--> <input id='button3' type='button' class='move' value='Add Days' /> <select id="daycombo1" class="mycombo1"> <option>SELECT</option> <option value="1">1</option> <option value="3">3</option> <option value="7">7</option> <option value="14">14</option> <option value="30">30</option> <option value="40">40</option> <option value="50">50</option> <option value="60">60</option> <option value="70">70</option> <option value="80">80</option> <option value="90">90</option> </select> Hi I have dropdown box which has value in days like 1,3,5,7,10,30,40... now I if I select from dropdown any value suppose 30 then (in my table there is one column name as add days which has dropdown too) it should update all values in dropdown as 30. Please let me know. Thanks in advance
  7. I have two drop down one is in form table and one is out side of table. if I want to update table coloumn(days) based on dropdown value(days) how would I do it? Please let me know if you need more description. Thanks
  8. you are right but I was trying to explain my problem in short form so it would not waste your time. Can you please help me? I am getting value for post_abc like this 0=>'3',dave,Read,06/09/2015 its selected value from checkbox. now I want to update selected value in sql server. I am sorry if I am not able to explain you properly. I am beginner. I hope you understand. Appricate your help.
  9. Guru I am trying to explain my problem as you said I have provided my code. now you said I am wasting your time.
  10. array (size=1) 'abc' => string '' (length=0) I am getting above answer when I do post. What I am trying to do here is I am selecting values from checkbox and trying to update in sql server database. Give me your ideas.
  11. <?php require_once("../includes/config.php"); ?> defined('DB_SERVER') ? null : define("DB_SERVER", "test5"); defined('DB_USER') ? null : define("DB_USER", "test1"); defined('DB_PASS') ? null : define("DB_PASS", "password"); defined('DB_NAME') ? null : define("DB_NAME", "DataLog"); <?php require_once "../includes/initialize.php" ?> <?php define('SITE_ROOT', 'C:'.DS.'xampp'.DS.'htdocs'.DS.'PhpProject1'); defined('LIB_PATH') ? null : define('LIB_PATH', SITE_ROOT.DS.'includes'); // load config file first require_once LIB_PATH.DS.'config.php'; ?> ignore this part <?php include_layout_template('header.php'); ?>
  12. Guru I have uploaded my code here. Can you please help me here?
  13. here is my issue again from first page I am getting value from checkbox like this below is value for ($_post['abc']) 0=>'1','xyz','06/08/2015 1=>'2','pqr','07/08/2015 what i want is id=>1 name=>xyz date=>06/08/2015 id=>2 name=>pqr date=>07/08/2015 Please let me know if you can get idea what i am talking about MERGED Here is my form and I am trying to update value in sql server <div class="container"> <form method="post" name="Update" action="update3.php" /> <table id="chkbx1" border="1" id="results" class="hovertable" > <thead> <tr > <th>check</th> <th>Lname</th> <th>Role</th> <th>ExpireDate</th> <th>Add Days</th> </tr> </thead> <tbody> <?php $serverName = DB_SERVER; $connectionInfo = array("UID" => DB_USER, "PWD" => DB_PASS, "Database" => DB_NAME); $conn = sqlsrv_connect($serverName, $connectionInfo); if ($conn === false) { die(print_r(sqlsrv_errors(), true)); } // Change SQL HERE Season DESC or Season to sort by FALL or SUMMER $sql = "select datarooms.Dataroomid,memberinfo.lastname,role,dateexpire,memberinfo.memberid from" . " datarooms join membership on membership.dataroomid=datarooms.dataroomid " . " join memberinfo on memberinfo.memberid=membership.memberid " . " where datarooms.Dataroomid= '" . 69 . "' order by datarooms.expdate desc"; $stmt = sqlsrv_query($conn, $sql); if ($stmt === false) { die(print_r(sqlsrv_errors(), true)); } $counter = 1; while ($row = sqlsrv_fetch_array($stmt)) { echo '<tr>'; echo '<td>' . '<input id="abc" type="checkbox" name=abc[] " value="' . $row['memberid'] . '" ">' . '</td>'; echo '<td style="display:none;">' . $row['memberid']. '</td>'; echo '<td>' . $row['lastname'] . '</td>'; //echo '<td>'.$row['role'].'</td>'; echo "<td>" . '<select id="combo' . $counter . '" name="combo" class="mycombo" >' . '<option '; if ($row['role'] == "Administrator") { echo "selected"; } echo '>Administrator</option>' . '<option '; if ($row['role'] == "Read-Only") { echo "selected"; } echo '>Read-Only</optiion>' . '<option '; if ($row['role'] == "Contributor") { echo "selected"; } echo '>Contributor</optiion>' . '<option '; if ($row['role'] == "View-Only") { echo "selected"; } echo '>View-Only</optiion>' . ' </select>' . "</td>"; echo '<td>' . date_format($row['dateexpire'], "m/d/Y") . '</td>'; echo "<td>" . '<select id="daycombo" class="mycombo" > <option>1</option> <option>3</option> <option>7</option> <option>14</option> <option>30</option>' . '</select>' . "</td>"; echo '</tr>'; $counter++; } echo '</tbody>'; echo '</table>';// echo "<input type='submit' id='button1' name='submit' value='submit' style='float:center;margin-top:220px;' >"; echo "<input id='button1' type='button' class='move' value='Submit'style='float:left;margin-top:400px;'';/>"; sqlsrv_free_stmt($stmt); ?> </tbody> </table></form></div><!--<script src="../assets/js/jquery.dataTables.min.js"></script><script src="../assets/js/datatables.js"></script>--><script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js" type="text/javascript"></script><script type="text/javascript"> $('#button1').click(function() { iterate(); }); $(".mycombo").change(function() { ($(this).find("option:selected").text()); }); function iterate() { var values = new Array(); $.each($("input[name='abc[]']:checked").closest("td").siblings("td"), function(i, idx) { if ($(this).find("select").attr("class") == "mycombo") { values.push($(this).find("option:selected").text()); } else { values.push($(this).text());// alert("value: " + values.join(", ")); } }); var url = 'update3.php'; var form = $('<form action="' + url + '" method="post">' + '<input type="text" name="abc" value="' + values + '" />' + '</form>'); $('body').append(form); $(form).submit(); }</script> MERGED On update 3 I want to update selected record in sql server. Guru here is my code. please help me now
  14. but I can not copy code here. how can i copy here in this forum?
  15. I am getting an error that Invalid argument supplied for foreach() Sorry I am beginner and I am giving you lot of troubles. But thanks for your patience and help. I really appriciate
  16. if I select first checkbox I am getting answer as I expected but If I check another checkbox I am getting array_Combine(): both parameter should have an equal number of elements Boolean false error
  17. It give me below error array_combine():both parameters should have an equal number of elements Boolean false
  18. Guru Yo are close to what I was aksing here is my $_post['abc'] result $_Post['abc']='1,xyz,06/04/2015' now when I explode it result would be like this 0=>1 1=>'xyz' 2=>'06/04/2015' and when I do it list($id,$name,$date)=explode(',',$_POST['abc']) I am getting result id=>1 name->'xyz' date=>'06/04/2015' but I want to get id,name and date for each element. I have tried the way you shown in above post but I am not getting any result. no array. Please let me know how can I show id,name ,date for each selected array index Thanks in advance and guys I am beginner not pro. so ia m kindly asking your help.
  19. no I don't want to type $_post['abc'] I just want to show my field name for each array index
  20. I am getting data using $_post['abc'] and all values will be on 0 index but later I explode it all values
  21. Sorry I dint mean it like that. result would be like this for $_post['abc'] 0=>1,xyz,06/04/2015
  22. it contain selected value from checkbox and its an array
×
×
  • 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.