Custom Bots
We create custom IM bots.
Black Green Blue Red Gold
RSS
  • Home PageHome
  • Customize Your Bot / Hire a Freelancer
  • How to Create a Custom Bot / Bot Making Software
  • IMDB to WordPress
  • Youtube Comment Poster Bot

Sum of the values by date

Codes & Scripts Add comments

Hello, I have read the tutorials, searched forums for 2 weeks, and not found the assistance I require. I now jump in to ask my questions…

I am new to this arena, so I honor your kindnes to my situation.

I have 2 Solar Inverters I have at my home, and I have a RS232 data port on each that is now connected to my home network via an IP converter to upload the data of the power they make each hour to a simple website I made, so I can see what is going on durring the hours I am at work. The information goes to my FTP site and the data falls into the table perfectly. I am trying to get the PHP and MySQL code to list the data into the forms/tables on the web page. For this project I have set up Dreamweaver and a test server on my home PC, to get this working. All the data on the web host MySQL is the same as in the test server (other then the host, name, and password but it works fine).

I have a basic MySQL Table…

+---------+----------+------------+---------+------------+----------+
| Unit ID |  Date    |    Time    |  Power  |  Volts     |  Current |
+---------+----------+------------+---------+------------+----------+
|    1    |YYYY-MM-DD|  12:00:00  |  560    |   XXXX     |   XXXX   |
+---------+----------+------------+---------+------------+----------+
|    1    |YYYY-MM-DD|  13:00:00  |  560    |   XXXX     |   XXXX   |
+---------+----------+------------+---------+------------+----------+
|    2    |YYYY-MM-DD|  12:00:00  |  490    |   XXXX     |   XXXX   |
+---------+----------+------------+---------+------------+----------+

Etc....

I am able to SUM the Total “Power” of all the “Power” Rows with…

<?php
$con = mysql_connect("localhost","NAME","PASWORD");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("inverters", $con);
$qry = mysql_query(" SELECT SUM(Power) AS total FROM feed ");
$row = mysql_fetch_assoc($qry);
echo $row['total'];
mysql_close($con);
?>

I have been trying for weeks to get “the current day power”, the month power etc…

I have thought about having a “This Week”, but lord only knows how long that would take… hahaha

As seen on the website.

+-----------+----------------+-----------------+-----------------+
| Today (W) |  This Month    |    This Year    |  Lifetime Power |
+-----------+----------------+-----------------+-----------------+
|????????| ??????????|???????????|----working----|
+-----------+----------------+-----------------+-----------------+

For the Current Day, I have tried this, but it does not work…

$query = mysql_query("SELECT SUM(Power) ORDER BY(Time) CURDATE(), AS 'day_total' FROM feed ");
$result = mysql_fetch_array($query);
$daytotal = $result["day_total"];
echo $row['day_total'];

For the YEAR, I have tried this, but it does not work…

$query = mysql_query("SELECT SUM(Power) AS year_total FROM feed WHERE YEAR(date) = YEAR(CURDATE());");
$result = mysql_fetch_array($query);
$yeartotal = $result["year_total"];

I have not even got to the month yet as I am reading and reading. Online I see how to get user names, and the time they register, and how many visit hits per year or month etc, but none have been informative to my situation. I think the more I read on the PHP and MySQL website, the more stupid I have become (as you can verywell see from the code above.

Using Google to seach how to get the Current Date only showes me how to enter the current date in a row, not how to SUM the values of the current day.

I would greatly honor any assistance to my learning and functioning of this.

Thank You,

Alan

Related Posts:

  • MySQL Query: R? Newspaper Group Results hour minute | | | days | and f? Cases L? Press with empty table Assistance
  • How do I create a function to retrieve values ??from the database
  • Using Php and Mysql to Develop a Cms
  • ?
  • Self-taught Php/mysql: a Simple Page Counter Tutorial

November 4th, 2010  
Tags: date, values

Leave a Reply

CAPTCHA Image CAPTCHA Audio
Refresh Image

Custom Bots Sponsors

  • Categories

    • Codes & Scripts
    • Custom Requests
    • Download
    • Entertainment
    • Free Downloads
    • games-entertainment
    • How To/Articles
    • Marketing
    • Review
    • Seo Services
    • Software
    • Video Tutorial
    • Youtube
  • Recent Posts

    • BASE DE DATOS EN VISUAL BASIC CON ADO – CECYTEM TECAMAC 3/4
    • BASE DE DATOS EN VISUAL BASIC CON ADO – CECYTEM TECAMAC 3/4
    • Internet sales of drugs locally
    • Andriod App st rzt from? Installing
    • Booking data. aspx page to third-party PHP Site
    • Everything You Need To Know About Windows
    • Netmobiweb – Marketing in cellular and mobile Ren – In Internet Marketing
    • Unrecoverable git push?
    • Spare Room (mughal959)
    • php tutorial – 2.07 comments
  • Blogroll

    • Rock Kitty
Categories
  • Codes & Scripts
  • Custom Requests
  • Download
  • Entertainment
  • Free Downloads
  • games-entertainment
  • How To/Articles
  • Marketing
  • Review
  • Seo Services
  • Software
  • Video Tutorial
  • Youtube
About Me

Write about yourseft, This is just a sample: Welcome to iSoftwareReviews where you can find reviews, ratings, comparisons about variety of computer software programs.

Hi, my name ChanDara and I am a software programmer, web design and development, graphics designer, software trainer, software consultant. And I have worked in IT for more than... Read more

Free Wordpress Themes | Copyright © 2012 Custom Bots All Rights Reserved XHTML CSS THEME by I SOFTWARE REVIEWS