Results 1 to 1 of 1

Thread: View entries from last 7 days

  1. #1
    Join Date
    Dec 2005
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default View entries from last 7 days

    Can anyone help me sort this out please

    I want to pull all entries in the last 7 days
    I have this so far


    Database
    Code:
    film_info
    Tables
    Code:
    films
    
    -------------------------------------
    
    Film_Id  Title  Info  Download  View  Year  Extras  TIMESTAMP

    Page
    Code:
    <?php
    $con = mysql_connect("localhost","film_info","Hmmm");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("film_info", $con);
    
    $result = mysql_query("SELECT * FROM `films` WHERE `TIMESTAMP` condition 'DATE_SUB( NOW(), INTERVAL 7 DAY'"); 
    
    echo "<body bgcolor=\"black\" text=\"red\" link=\"fuchsia\" vlink=\"purple\" alink=\"fuchsia\">\n";
    echo "  <center>
    <h1><b><font size=6 color=red>Last 7 Days</font></b></h1>
    </center> <left>
    <table border='0'>
    <hr></left>" ;
    
    $i = 0;
    while($row = mysql_fetch_array($result))
      {
      $i++;
    
      echo "</br>";
      echo  "<b><font size=5 color=fuchsia>{$row['Title']}</font></b>";
      echo "</br>";
      echo "</br>";
      echo  "<b><font color=red>Genre: </font></b><font color=fuchsia>{$row['Extras']}</font>";
      echo "</br>";
      echo "</br>";
      echo  "<b><font color=red>Plot:   </font></b><font color=fuchsia>{$row['Info']}</font></b>";
      echo "</br>";
      echo "</br>";
      echo  "<a href=http://somewhere/filesarehere/{$row['Download']}>Download</a>";
      echo "   -  -  ";
      echo "<a target='main' href='http://somewhere/filesarehere/{$row['View']}'>View</a>";
      echo "</br>";
      echo "</br>";
      echo "<hr>";
      }
    ?>
    the page works when I use
    Code:
    $result = mysql_query("SELECT * FROM films WHERE year = 2007"); 

    Anyone have any idea



    FIXED

    Code:
    $result = mysql_query("SELECT * FROM `films` WHERE `TIMESTAMP` > DATE_SUB( NOW(), INTERVAL 7 DAY)");
    Last edited by Feckie; 05-17-2009 at 01:18 PM.

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
  •