Filter a date field.

then you have to use:

Code:
if($show == "new")
    $sql .= " SELECT * FROM $sql WHERE added > (NOW() - INTERVAL 30 DAY)";

as its the way everything is stored and therefore should be done the same way :)
 
Okay,

Maybe it should work, but it doesn't...

This works, but shows all of the sites in the whole directory:
if($show == "new"){
$sql .= "added";
}

This shows nothing at all:
if($show == "new"){
$sql .= " SELECT * FROM $sql WHERE added > (NOW() - INTERVAL 30 DAY)";
}

(which is the way it looks like now here: http://www.enhancementresearch.com/partners/directory/new.html)

By the way, this is the resulting query using:
if($show == "new"){
$age = date("Ymd", date("U") - date("t")*24*60*30);
$age .= "000000"; // pad $age to a 14 digit number
$sql .= " WHERE Added > $age ";

Code:
select phplinks_links.ID as site_id, phplinks_links.SiteName as site_name, phplinks_links.SiteURL assite_url, phplinks_categories.Category as category_name, phplinks_categories.ID as cat_id,phplinks_links.Added as added, phplinks_links.LastUpdate as last_update, phplinks_links.Descriptionas site_description, phplinks_links.Country as country, phplinks_links.HitsIn as hits_in,phplinks_links.HitsOut as hits_out, count(phplinks_reviews.ID) as total_reviews from phplinks_linksWHERE phplinks_links.Added > 20050215000000 left join phplinks_categories onphplinks_links.Category = phplinks_categories.ID left join phplinks_reviews on phplinks_links.ID =phplinks_reviews.SiteID group by site_id order by Added desc limit 0, 10
 
try excecuting ONLY the time query..

i think you should edit it so it wouldnt be SELECT * FROM but place "added > (NOW() - INTERVAL 30 DAY)" in your where clause BEFORE ORDER BY
 
Alexi,

Thank you very much for your time in trying to assist me.

I tried both ways, putting both in fromt of the whole quiry and making that the only quiry and still nothing...I can't figure out why this is so difficult for us to do...
 
use mysql_query($sql) or die(mysql_error());

while $sql is a time query and then while its the full query...

are you getting any errors?
 
Full query:
mysql_query($sql) ----------- There is no change
echo mysql_query($sql) ------ It says: Resource id #13
die(mysql_error()); ----------- Blank screen as if the program just quit

Time only query:
mysql_query($sql) ----------- There is no change
echo mysql_query($sql) ------ There is no change
die(mysql_error()); ----------- Blank screen as if the program just quit

Hope this helps...By this it looks like there is some error per the die(mysql_error()); results...how do we figure out what the error is?

I tried
echo die(mysql_error());
and
echo mysql_error();

And there was no irregular output...
 
Oops sorry about that :shock:

Okay when I use that line with the full query, there is no error.

When I use this:
$sql .= " SELECT * FROM $sql WHERE added > (NOW() - INTERVAL 30 DAY)";
I get this error:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE added > (NOW() - INTERVAL 30 DAY)' at line 1

However when this query is used...there is nothing to query, I mean there is no conection with $tb_links in the above query at all...
 
Back
Top