jquery - PHP GET and Load in a div -
i have new structure getting date, connect php file... jquery documentation followed letter, need php file date, select data mysql table , put div waiting it.
here jquery script...
$(document).ready(function () { $('#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.php', {choice: datetext}, function() { $(this).show(); }); $('#apdiv8').load('yearpower.php', {choice: datetext}, function() { $(this).show(); }); $('#apdiv10').load('yeargraph.php', {choice: datetext}, function() { $(this).show(); }); }}); });
here php
<? $choice = (isset($_get['choice'])) ? date("y-m-d",strtotime($_get['choice'])) : date("y-m-d"); $con = mysql_connect("localhost","root","mackie1604"); 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); ?>
why wont php work ?
well here how entire code should like
Comments
Post a Comment