Jump to content

New if within 7 days


wwfc_barmy_army

Recommended Posts

  • Replies 56
  • Created
  • Last Reply
OK. Delete the while loop.

Put this code in its place:
[code]print "<PRE>";
print_r($qry);
print "</PRE>";[/code]

Is there any output from the array? If so, what is it?
-----------------
BTW, what is this script used for? Is it a script that lists several entries or is it just supposed to list information about a single entry?
The script lists information from one record (which is currently just rubbish typed in) but this is what the array said:
[quote]Array
(
    [0] => 9
    [id] => 9
    [1] => cx
    [name] => cx
    [2] => vcxvx
    [sitelink] => vcxvx
    [3] => xbv
    [sitedownload] => xbv
    [4] => 2006-09-13
    [dateadded] => 2006-09-13
    [5] => xbvb
    [publisher] => xbvb
    [6] => Pujhjdshfksjdhfjkhsdjkhfs
    [publisherinfo] => Pujhjdshfksjdhfjkhsdjkhfs
    [7] => 0
    [filesize] => 0
    [8] => bxcb
    [limitations] => bxcb
    [9] => vcxbvxv
    [requirements] => vcxbvxv
    [10] => 3D
    [graphics] => 3D
    [11] => bvxxcbvxbv
    [review] => bvxxcbvxbv
    [12] => vbbvxv
    [pros] => vbbvxv
    [13] => vcbxbvbvx
    [cons] => vcbxbvbvx
    [14] => 0
    [editorrating] => 0
    [15] =>
    [screenshot] =>
    [16] => 0
    [rating] => 0
    [17] => 0
    [num_votes] => 0
    [18] => 0
    [clicks] => 0
)[/quote]
OK, great! I think the problem is solved.

Turns out you don't even need that while loop.

[code]
<?php
date_default_timezone_set("US/Eastern");

list($year, $mon, $day) = explode('-', $qry[dateadded]);

$sevenDays = (7 * 24 * 60 * 60); // 604,800 seconds in 7 days
$entryTime = strtotime("$year-$mon-$day");
$now = strtotime("now");

if (($now - $entryTime) < $sevenDays)
{
echo "<img src='/images/new.gif'>";
}
?>[/code]

What are the results of this code?
[code]<?php
date_default_timezone_set("US/Eastern");

list($year, $mon, $day) = explode('-', $qry[4]);

$sevenDays = (7 * 24 * 60 * 60); // 604,800 seconds in 7 days
$entryTime = strtotime("$year-$mon-$day");
$now = strtotime("now");

if (($now - $entryTime) < $sevenDays)
{
echo "<img src='/images/new.gif'>";
}
else
{
echo "<PRE>";
echo "This script is mind-boggling!";
echo '$qry[4] --> '.$qry[4]."\n";
echo '$now --> '.$now."\n";
echo '$entryTime --> '.$entryTime."\n";
echo '$sevenDays --> '.$sevenDays."\n";
echo '$year-\$mon-\$day --> '.$year."-".$mon."-".$day."\n";
echo "<PRE>";
}
?>[/code]

This script had better produce some output! That's why I added the else{} statement.

If things don't work right: Please post the output of this snippet. Also email or post your source for site.php. I'll look for any syntax errors.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.