SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Php Question

  1. #1
    SitePoint Member
    Join Date
    Feb 2001
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey everyone!

    I have been trying to implement Php & MySQL into my website, but I do have a few questions. I am maintaining an archive and I would like to have a place where it shows when the latest update has been made to the archive. How would I go about doing this? Would I have to search the entire contents of the database to find the latest date? For each submission, a date field is used (and has a value). Is there a more efficient method? As well, if I wanted to count the number of submissions (or row) within a database, how do I do that?

    Thanks for any help!

    Regards,

    Leo Chan

  2. #2
    Database Jedi MattR's Avatar
    Join Date
    Jan 2001
    Location
    buried in the database shell (Washington, DC)
    Posts
    1,107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Leo Chan
    [B]Hey everyone!

    I have been trying to implement Php & MySQL into my website, but I do have a few questions. I am maintaining an archive and I would like to have a place where it shows when the latest update has been made to the archive. How would I go about doing this?


    Execute:
    Code:
    SELECT * FROM archive ORDER BY date_column DESC LIMIT 1;

    Would I have to search the entire contents of the database to find the latest date? For each submission, a date field is used (and has a value). Is there a more efficient method? As well, if I wanted to count the number of submissions (or row) within a database, how do I do that?


    Execute:
    Code:
    SELECT COUNT( * ) FROM archive;
    to find the number of items in it.

    Thanks for any help!

    Regards,

    Leo Chan

  3. #3
    SitePoint Member
    Join Date
    Feb 2001
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for your response!

    actually.. i wasn't too clear on my question.. if i wanted let's say.. ALL the new additions to the archive from the latest date (like multiple returns.. instead of just one).. how would i do that? because the limit function only limits the number of items returned.. i want all the items returned for the latest update of the archive.. thanks!

    regards,

    leo chan

  4. #4
    Database Jedi MattR's Avatar
    Join Date
    Jan 2001
    Location
    buried in the database shell (Washington, DC)
    Posts
    1,107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In that case you would want to execute:
    Code:
      SELECT * 
        FROM archive 
       WHERE date_column > $some_date
    ORDER BY date_column DESC;


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
  •