Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Daily update to PHP page

    Hi, hope someone can help me, I'm very new to PHP, I am changing the website for the company I work for to so that it is updated daily with customer testimonials (1 new testimonial per day)

    How do I update get the site to update on a daily basis with a different testimonial?

    I understand some of the basics I am just struggling with how to put it all together.

    If someone can point me in the right direction I would be very grateful.

    Cheers
    Phil

  • #2
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    You can use a cron job to say go to the database where testimonials are stored and check if there is any new ones if so then get the oldest new one mark it as old then display it until the next cron job is run when the next cron job comes it'll do the same thing.. check for new testimonial if not use the existing one..

  • #3
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    You could also use PHP to switch the testimonial when someone visits the page.
    It will only switch once per day, but is triggered by the first person that visits the page.

    You didn't tell us how your testimonials are stored (database, or files?)

    If you have a bunch of them each stored as text files, like:
    071708.txt
    071808.txt

    You could use today's date to load the filename that matches the date.
    That means you would need to be creating new testimonials all the time.

    It might be better to just put a hundred of them in a directory, with
    any type of filename and randomly grab one ... make the testimonial
    randomly change each time a person visits the page (or refreshes it).

    EDIT:
    To display one (like the example above) ...

    <?php include("071708.txt")?>

    Will display that text file wherever you put the PHP include.


    .
    Last edited by mlseim; 07-17-2008 at 01:08 PM.

  • #4
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    You could also use PHP to switch the testimonial when someone visits the page.
    It will only switch once per day, but is triggered by the first person that visits the page.

    You didn't tell us how your testimonials are stored (database, or files?)

    If you have a bunch of them each stored as text files, like:
    071708.txt
    071808.txt

    You could use today's date to load the filename that matches the date.
    That means you would need to be creating new testimonials all the time.

    It might be better to just put a hundred of them in a directory, with
    any type of filename and randomly grab one ... make the testimonial
    randomly change each time a person visits the page (or refreshes it).

    EDIT:
    To display one (like the example above) ...

    <?php include("071708.txt")?>

    Will display that text file wherever you put the PHP include.


    .
    Thanks both for the input.

    My original plan was to store the testimonials in a database, they are not particularly big, 2 paragraphs at most.

    Would using txt files be a better way of doing this?

  • #5
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    This would be a perfect opportunity to learn some MySQL (a good thing to know),
    but it would be very much easier and quicker to just use a simple text file.

    It really depends on who is maintaining the testimonials.
    Is someone adding to the file every day? Do they have easy FTP access
    and know how to edit and upload that text file? Are you going to specifically
    change it each day, or do a random thing?

    If you have a "non techie" person that is updating the list, and needs to do it
    online, that complicates the matter because you'll have to create a simple
    online editor.

    It would be bad if someone needs to add or change these every day or week.
    After a couple of weeks, they'll get pretty sick of it and it won't happen anymore.

    You can see how this simple idea can escalate into a project where customers
    send a testimonial, and your PHP scripting actually stores them in a database and
    your client checks "yes" or "no" as to whether or not that testimonial will appear.
    That requires PHP/MySQL and a bunch of scripting on your part ... but that system
    is pretty much automatic.

  • Users who have thanked mlseim for this post:

    philm (07-17-2008)

  • #6
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Well the idea is to have a bunch of testimonials that we upload as and when the come in. It will be me that adds them to the database.

    I am thinking that it might be easier to have this update to a new testimonial as the page is refereshed or when someone new lands on the page.

    I like the idea of readers/customers being able to add their own testimonials at some point.

  • #7
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Displaying randomly would be easiest.

    A text file with each one on it's own line ...

    Say this file is called "testimonial.txt":

    Your product really helped me out!
    This product let my business grow and become a multi-million dollar business.<br />A great program you have!
    We started with 10 clients and ended up with 1000 clients in 6 months!


    Your PHP script would be like this (at the top of your page "index.php") ...

    PHP Code:
    <?php
    $quote 
    file("testimonial.txt");
    shuffle($quote);
    ?>
    Wherever you want to display it on your page, you put this ...

    <?=$quote[0]?>

  • Users who have thanked mlseim for this post:

    philm (07-29-2008)

  • #8
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts
    That works perfectly, thanks for your help


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •