Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Jake Giddens on September 2, 2007 at 11:02 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!

    Jake Giddens replied 18 years, 11 months ago 3 Members · 9 Replies
  • 9 Replies
  • Abraham Chaffin

    September 3, 2007 at 2:45 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

  • Jake Giddens

    September 3, 2007 at 3:26 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”

  • Jake Giddens

    September 4, 2007 at 2:33 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!

    TheIce Cream Man

  • Abraham Chaffin

    September 4, 2007 at 2:15 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

  • Jake Giddens

    September 4, 2007 at 9:10 pm

    Oh that’s brilliant! Thanks a million.

    TheIce Cream Man

  • Polako

    September 5, 2007 at 10:26 pm

    thanks

  • Jake Giddens

    September 10, 2007 at 7:08 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

    “;

    TheIce Cream Man

  • Abraham Chaffin

    September 10, 2007 at 7:56 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

  • Jake Giddens

    September 10, 2007 at 9:01 pm

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

    TheIce Cream Man

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy