SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Returning a total over a specified time from a single column

    Hi,

    I have written this query but it does not display anything. What I am attempting to do, is to add up a total of 'flighttime' column, and display it only for the current day. The flighttime column is structured as a varchar, not by time.

    Code:
    $query = 'SELECT (SELECT COUNT(*) FROM `flighttime` WHERE `pilotid` = ID) as total, submitdate * FROM db_pireps';		
    $today = date('Y-m-d');
    $submitdate = $query['submitdate'];
    					
    if($submitdate == $today)
    {
          mysql_fetch_array($query);
    }
    echo $query->total;

  2. #2
    SitePoint Zealot 2ndmouse's Avatar
    Join Date
    Jan 2007
    Location
    West London
    Posts
    196
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    couple of things.

    1. You have assigned $query to a string value, then you try to assign $submitdate by using $query as if it were an array - this won't work

    2. You need to assign a variable to the result of mysql_fetch_array. You can then run through the values in the returned array with a foreach loop
    Detect file changes remotely. SimpleSiteAudit is an early
    warning anti-hacker system which sends an alert on detection.

    PHP Find Orphan Files - Finds all the unreferenced files on your site.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •