FORUMS: list search recent posts

PHP

COW Forums : Web Design

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
IceCreamManPHP
by on Sep 2, 2007 at 11:02:58 pm

This is what I'm using to display the pages updated within a week for a website:

Code:
if ($last_edit > date("Y-m-d", strtotime ("-8 days"))) echo "$page_name -- $last_edit
"; else echo "";


Only thing is I want to make it so that it will not repeat itself if it's already listed. How do I go about doing this?

Hope I described my problem well enough.

Thanks!



Return to posts index

AbrahamRe: PHP
by on Sep 3, 2007 at 2:45:54 pm

Create an array to store items that you display. For instance

$page_name_displayed=array(); //ARRAY FOR CHECKING IF IT'S THERE

if(!in_array($page_name,$page_name_displayed)){ //CHECK IF IT'S THERE
$page_name_displayed[]=$page_name; //ADD TO THE ARRAY SO IT DOESN'T SHOW UP AGAIN

if ($last_edit > date("Y-m-d", strtotime ("-8 days"))) echo "$page_name -- $last_edit
"; else echo "";

}

Abraham


Return to posts index

IceCreamManRe: PHP
by on Sep 3, 2007 at 3:26:45 pm

Thanks Abraham. I actually just found out that there's an even easier way to do it. $last_edit is coming from a database so I just made it: GROUP BY 'page_name'

The "Ice Cream Man"


Return to posts index


IceCreamManRe: PHP
by on Sep 4, 2007 at 2:33:37 am

Here's a new one:

Is there a way I can display the number of vistors currently viewing a page? I'm pretty sure this can be done - I'm just not sure on how to go about doing this.

Thanks in advance!

The "Ice Cream Man"


Return to posts index

AbrahamRe: PHP
by on Sep 4, 2007 at 2:15:56 pm

To calculate the number of people currently viewing a page is a little tricky. You could get the exact number with an AJAX function that monitored your user and continually corresponded with a script and stored the information.

If you don't know AJAX you can do something like create a database that stores the IP, time stamp, and URI then display the count for the last 5-10 minutes.

Abraham


Return to posts index

IceCreamManRe: PHP
by on Sep 4, 2007 at 9:10:21 pm

Oh that's brilliant! Thanks a million.

The "Ice Cream Man"


Return to posts index


polakoRe: PHP
by on Sep 5, 2007 at 10:26:55 pm

thanks


Return to posts index

IceCreamManRe: PHP
by on Sep 10, 2007 at 7:08:43 pm

This is a bit from a code I have been using for a certain website for about a month now. It has been working fine until today I noticed it displayed the else statement for articles that where edited today (September 10th, 2007). I've been playing around with it trying to fix this, and haven't had any success - but I can simply cannot understand why it is doing this. I alos noticed it will repeat this for tomorrow and the day after. Any thoughts? THANKS!


$query = "SELECT *, DATE_FORMAT(last_edit, '%M %D, %Y') as last_edit FROM database WHERE `page_name` like '$page_name' AND `side` LIKE 'l' AND `position` > 0 ORDER BY `position`";


if ($last_edit > date("F jS, Y", strtotime ("-8 days"))) echo "
Updated $last_edit
"; else echo "
$last_edit
";

The "Ice Cream Man"


Return to posts index

AbrahamRe: PHP
by on Sep 10, 2007 at 7:56:20 pm

Well not sure exactly what the problem is as I'm not seeing the entire code but I would suggest doing a direct strtotime compare.

Probably no need to format the mysql date before you pull it since strtotime is so flexible. Do something like

if(strtotime($lastedit)>strtotime('-8 days')){
echo('it is');
}else{
echo('it isn't');
}

Abraham


Return to posts index


IceCreamManRe: PHP
by on Sep 10, 2007 at 9:01:32 pm

You are amazing. Thank you for once again getting me out of trouble.

The "Ice Cream Man"


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]