php - Dates do not post right -


i seem going no place fast...

can't seem single inline(embeded) jquery datepicker datetext post php , mysql correctly return data table.. reading has me understand should right, not. datepicker select have several events trigger single select... data being requsted day, month, , year sending date create highcharts graph of data hours of day, days of month, , months of year.

the table simple... date, time, power

here javasctipt...

$(document).ready(function () {      $('#datepicker').datepicker({onselect: function(datetext) {         var mydate = $(this).datepicker('getdate');         $('#apdiv1').html($.datepicker.formatdate('dd, d', mydate));         $('#apdiv5').html($.datepicker.formatdate('mm', mydate));         $('#apdiv7').html($.datepicker.formatdate('yy', mydate));         $.post('daypower.php', {choice: datetext.val}, function(data) {             $('#apdiv2').html(data).show();         });         $.post('daygraph.php', {choice: datetext.val}, function(data) {               $('#apdiv4').html().show();         });         $.post('monthpower.php', {choice: datetext.val}, function(data) {             $('#apdiv6').html(data).show();         });         $.post('monthgraph', {choice: datetext.val}, function(data) {               $('#apdiv9').html().show();         });         $.post('yearpower.php', {choice: datetext.val}, function(data) {             $('#apdiv8').html(data).show();         });         $.post('yeargraph', {choice: datetext.val}, function(data) {               $('#apdiv10').html().show();         });   }}); 

});

here php post getting data day (daypower.php)...

    <? if(isset($_post['choice'])) $choice = (isset($_post['choice'])) ? date("y-m-d",strtotime($_post['choice'])) : date("y-m-d"); $con = mysql_connect("localhost","root","xxxxxxxx");  if (!$con)  {  die('could not connect: ' . mysql_error());  }  mysql_select_db("inverters", $con);   $sql = 'select sum(power) power '         .'from feed '        .'where date = $choice'; $res = mysql_query($sql) or die('sql='.$sql."\n".mysql_error()); $row = mysql_fetch_assoc($res); echo $row['power'];  ?> 

the first , second line of php should date datepicker, , put date mysql can read, , sql select should values table , echo div have told go... doing wrong ?

thanks,

alan

i have jquery post php file script...

 $('#datepicker').datepicker({dateformat: 'yy-mm-dd', onselect: function(datetext) {         var mydate = $(this).datepicker('getdate');         $('#apdiv1').html($.datepicker.formatdate('dd, d', mydate));         $('#apdiv5').html($.datepicker.formatdate('mm', mydate));         $('#apdiv7').html($.datepicker.formatdate('yy', mydate));         $('#apdiv2').load('daypower.php', {choice: datetext}, function() {               $(this).show();         });         $('#apdiv4').load('daygraph.php', {choice: datetext}, function() {               $(this).show();         });         $('#apdiv6').load('monthpower.php', {choice: datetext}, function() {               $(this).show();         });         $('#apdiv9').load('monthgraph', {choice: datetext}, function() {               $(this).show();         });         $('#apdiv8').load('yearpower.php', {choice: datetext}, function() {               $(this).show();         });         $('#apdiv10').load('yeargraph', {choice: datetext}, function() {               $(this).show();         });   }}); 

});

as new structure using load , not post, understanding must use in php, have made changes understand should work, not... seem in same boat before... here new php... ideas why not work ????

<?   $choice = (isset($_get['choice'])) ? date("y-m-d",strtotime($_get['choice'])) : date("y-m-d");  $con = mysql_connect("localhost","root","xxxxxxxx");   if (!$con)  {   die('could not connect: ' . mysql_error());   }   mysql_select_db("inverters", $con);    $sql = 'select sum(power) choice '          .'from feed '         .'where date = $choice';  $res = mysql_query($sql) or die('sql='.$sql."\n".mysql_error());  $row = mysql_fetch_assoc($res);  echo $row['choice'], '<br />';   mysql_close($con);  ?>  

i noticed you're using datetext.val. seems me according documentation, datetext string:

the function receives selected date text , datepicker instance parameters.

now, second parameter function input element. want call .val() on (note brackets well).

try changing: $('#datepicker').datepicker({onselect: function(datetext) {
to: $('#datepicker').datepicker({onselect: function(datetext,inst) {
, change datetext.val inst.val().


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -