PHP-Selecting contents of a table according to the date selected using datepicker

edavreda

New Member
Following is a stored procedure for getting data from database . When i click on get i need all the data that is associated with the specific date mentioned in the date picker to be displayed.\[code\]SELECT EP.Employee_Id,TD.Training_Id,TD.Training_Date,DT.Topic_Name,EP.Employee_Name FROM `training_details` TD INNER JOIN`domain_topics` DT ON DT.Domain_Id=TD.Domain_Id INNER JOIN `trainer_details` TRDON TRD.Training_Id = TD.Training_IdINNER JOIN`employee_profile` EPON TRD.Trainer_Id = EP.Employee_IdWHERE TD.Training_Date BETWEEN '2012-12-01' AND '2012-12-31'; \[/code\]Using this SP i get all the data between the mentioned date. Now what i want is like when i select a date using datepicker and click on get button i need all the data of the mentioned dates only.Here is my HTMl code\[code\]<script type="text/javascript" language="javascript"> $.getJSON('from_to.php',null,function(data) { $('#submit_date').click(function() { if (data) { $.each(data, function (i, element) { $('#From_To_Filter').append('<tr><td >' + element.Training_Date + '</td><td >' + element.Topic_Name + '</td><td>' + element.Employee_Name + '</td></tr>'); }); } }); }); $(function() { $( "#from_datepick" ).datepicker({ defaultDate: "+1w", changeMonth: true, numberOfMonths: 1, onClose: function( selectedDate ) { $( "#to_datepick" ).datepicker( "option", "minDate", selectedDate ); } }); $( "#to_datepick" ).datepicker( { defaultDate: "+1w", changeMonth: true, numberOfMonths: 1, onClose: function( selectedDate ) { $( "#from_datepick" ).datepicker( "option", "maxDate", selectedDate ); } }); }); </script> <body> <h2 class="h2_tag"> Training Info </h2> <div id="fromtodate"> <span id="from_label"> From </span> <span id="fromdatepicker"> <input type="text" id="from_datepick" name="from"/> </span> <span id="to_label"> To </span> <span> <input type="text" id="to_datepick" name="to"/> </span> <span> <input type="button" id ="submit_date" href="http://stackoverflow.com/questions/14039258/#FilterDate" value="http://stackoverflow.com/questions/14039258/Get"> <div> <div id='FilterDate' > <fieldset > <legend> Training </legend> <div id="ShownCompletedFeedback1" > <table id="From_To_Filter" > </table> </div> </fieldset> </div> </div> </div> </span> </div>\[/code\]And my Php code is \[code\]<?phpdefine('HOST', 'localhost');define('USER', 'root');define('PASS', '');define('DBNAME', 'sample');$db = new mysqli(HOST, USER, PASS, DBNAME);if (mysqli_connect_errno()) {printf("Connect failed: %s<br/>", mysqli_connect_error());}$sql = "CALL From_to_Filter_sp()";$result_db = $db->query($sql);$result = array();while ($row = $result_db->fetch_assoc()) {$result[] = $row;}echo json_encode($result);$db->close();?>\[/code\]What alteration should i do for my requirement?
 
Back
Top