Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts

    Countdown frm last submission

    Hi,

    im giving full credits to tangoforce as he's written this mod for me :-)

    PHP Code:
    // 24 hr limit mod start.
                      //Get time and cal for last 24 hr time stamp
                      
    $Time time();
                      
    $Day = (60*60*24);
                      
    $Time = ($Time $Day);
                      
                      
    $Site mysql_real_escape_string($_POST['sname']);

                      
    //Lookup site and get its ID for next 2 queries
                      
    $Query_Site "select * from wcddl_sites where name='$Site'";
                      
    $Result_Site mysql_query($Query_Site);
                      
    $Row_Site mysql_fetch_array($Result_Site);

                      
    //Get number of downloads already stored within last 24hrs
                      
    $Query_Downloads "select * from wcddl_downloads where sid='$Row_Site[id]' and dat > '$Time'";
                      
    $Result_Downloads mysql_query($Query_Downloads);
                      
    $Count_Downloads mysql_num_rows($Result_Downloads);

                      
    //Get number of downloads in queue
                      
    $Query_Queue "select * from wcddl_queue where sid='$Row_Site[id]'";
                      
    $Result_Queue mysql_query($Query_Queue);
                      if (!
    $Count_Queue mysql_num_rows($Result_Queue))
                          {
                          
    //If nothing in queue and mysql_num_rows returns false, set to 0
                          
    $Count_Queue 0;
                          }
                          
                     
    //Get total count of everything submitted in last 24 hrs (inc queued items that have been submitted anytime)
                      
    $Total_Count = ($Count_Queue $Count_Downloads $Count_Downloads);
                          
                      for(
    $i=0$i count($titles); $i++) {//Loiop through download fields
                      //Non submitted fields still set due to dropdown menu 
    can any 1 help me on displaying tha time since lats submissions..

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,304
    Thanks
    57
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Thinking about this from another approach if its just the time of the last submission you want then from the downloads table you could run another 24 hr query and order it by asc (think its asc might need to try desc if it don't work).

    Something like:
    PHP Code:
    //Get time and cal for last 24 hr time stamp
    $Time time();
    $Day = (60*60*24);
    $Time = ($Time $Day); 

    //Get number of downloads already stored within last 24hrs
    $Query_Downloads2 "select * from wcddl_downloads where sid='$Row_Site[id]' and dat > '$Time' order by dat asc limit 1";
    $Result_Downloads2 mysql_query($Query_Downloads);
    $LastSubmission mysql_fetch_array($Result_Downloads2)); 
    $LastSubmission $LastSubmission['dat']; 
    Thats theoretical - i've not tested it. If it works then it will return the timestamp of the most recent submission in the downloads table.

    It should not be run in the core but somewhere in the main page itself otherwise you risk breaking the core and we both know how fragile that is!
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

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