Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3497618
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:23:33+00:00 2026-05-18T12:23:33+00:00

I have a sql table : date (Y-m-d) / time (00:00:00) / power (INT)

  • 0

I have a sql table : date (Y-m-d) / time (00:00:00) / power (INT)

When I select a date from an inline datepicker, I am trying to post 3 HighCharts graph (one-24 hours, two-31 days of month, three-12 months of year) and I need to get the values out of the table for the chart to be created.

For the day, I need the 24 values for each hour ‘100,200,300,200,300 etc..’

Here is the PHP for the “day” but it is not working…

<?php
$choice = (isset($_POST['choice'])) 
          ? date("Y-m-d",strtotime($_POST['choice'])) 
          : date("Y-m-d"); 
$con = mysql_connect("localhost","root","xxxxxx");  
if (!$con)  {  
  die('Could not connect: ' . mysql_error());  
}  
mysql_select_db("inverters", $con);  
$sql = "SELECT HOUR(time), COUNT(power) 
FROM feed 
WHERE time = DATE_SUB('".$choice."', INTERVAL 24 HOUR) 
GROUP BY HOUR(time) 
ORDER BY HOUR(time)"; 
$res = mysql_query($sql) or die('sql='.$sql."\n".mysql_error()); 
$row = mysql_fetch_assoc($res); 
echo $row['choice'].'<br />'; 
?>

This has been confirmed by another individual that the code does not work, would anyone have a helpful solution to fix the error ?

Alan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T12:23:33+00:00Added an answer on May 18, 2026 at 12:23 pm

    Thank you everyone for all your help !

    The problem was in the first string, I only had to change the date format in addition to your wonderful examles !

    $choice = (isset($_POST['choice'])) ? date("m",strtotime($_POST['choice'])) : date("m"); 
    

    Thank You Very Much !

    Alan

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in SQL Server 2005 which has a date time field.
I have the following pseudo-SQL schema: table flight id int primary key date timestamp
I have this JDBC SQL query: select * from table where TX_DATE = {d
I have a table in SQL Server with these records : ID Date Time
I have a table in SQL Server 2008 that stores date/time values as varchar(max)
I have a SQL table with the following schema: fruit_id INT price FLOAT date
I have the following SQL table - Date StoreNo Sales 23/4 34 4323.00 23/4
I have a table in sql where the date format is stored in Hijri.
In my SQL Server database schema I have a data table with a date
I have the following tables: --table sportactivity-- sport_activity_id, home_team_fk, away_team_fk, competition_id_fk, date, time (tuple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.