Hello Everyone,
I seem to be going no place fast...
Can't seem to get a single inline(embeded) jquery Datepicker dateText to post to the PHP and mysql correctly to return data from the table.. My reading has me to understand it should be right, but it is not. Now the datepicker select does have several events that trigger from the single select... data being requsted by the day, month, and year as well as sending the date to create a highcharts graph of data for hours of a day, days of a month, and months of a year.
The Table is very simple... date, time, power
Let me start to show how we get to the PHP...Here is the Javasctipt that makes the post. It should be sending the date selected...
Now the PHP here, this should take the date and format it to the format that mysql needs to see, and then grab the data and echo it into the div I have made and directed..
What could be wrong ?
If you do not understand what my meaning is, you can get a visual of what I am trying to do at http://www.pvmonitor.000a.biz/demo2.php
I seem to be going no place fast...
Can't seem to get a single inline(embeded) jquery Datepicker dateText to post to the PHP and mysql correctly to return data from the table.. My reading has me to understand it should be right, but it is not. Now the datepicker select does have several events that trigger from the single select... data being requsted by the day, month, and year as well as sending the date to create a highcharts graph of data for hours of a day, days of a month, and months of a year.
The Table is very simple... date, time, power
Let me start to show how we get to the PHP...Here is the Javasctipt that makes the post. It should be sending the date selected...
Code:
$(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();
});
}});
});
Code:
<?
$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) AS 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);
?>
If you do not understand what my meaning is, you can get a visual of what I am trying to do at http://www.pvmonitor.000a.biz/demo2.php
Comment