Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17
  1. #1
    Senior Member
    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    162
    Member #
    2563
    Hi all,

    I assume this is going to be a PHP related resolution but I haven't found any solutions as of yet. I have an image on my site which needs to change on certain dates. There is no fixed pattern to the dates, so sometimes I will need the next image to come up in a week, sometimes two weeks. At the moment I manually make the changes but want to automate the process. What I have already are all the images I need and the dates when particular images need to be shown.

    So it would work something like:

    From march 10th show image a here until otherwise told
    From march 20th show image b here until otherwise told
    From april 15th show image x here and so on

    Can anyone suggest how I would code this in PHP?

    Thanks in advance! :-)

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Im coding something for you..

    Can you tell us, is "here" always the same place?

    As in, image x will be different from time to time, but will always be on the same page?

  4. #3
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,720
    Member #
    5580
    Liked
    718 times
    m.mckernan ...

    While bfsog whips up a PHP script for you,
    go ahead and change the extension of your webpage(s)
    from .html to .php

    You'll need that .php extension to run the script that will be
    inserted into your existing web page. You're going to find that
    creating dynamic content using PHP will open up a whole new
    world for you.


  5. #4
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Okay here it is.

    A little about the script.

    1: It uses mysql to store the images filenames (not the images themselves).
    2: You can add new images to the database
    3: You can amend existing images
    4: It uses a username and password to login. If this is for a live site, you should ideally login against a database table aswell, using some encryption, but first things first.

    The script should be fairly simple for you to know what is going on, when you view it in your browsers

    addnew.php adds a new image to the database, it does not upload the image, I assume from your post they are already uploaded.
    update.php updates an image's filename. Lets say you have a row in your table that looks like:

    img_id = 1 img_filename = 'wdf.png'

    And you have code on myfavsite.php that displays the image with the id '1'.

    If you updated that image to google.jpg then on myfavsite.php, google.jpg would appear.

    demopage.php shows the PHP code you will need to place on the various pages to display different pages.

    I will let you play around on it - via http://bfsog.co.uk/testing/diffimage

    You require a login, which I have pm'ed you.

    You can download the complete script from: http://bfsog.co.uk/testing/diffimage/diffimage.rar

    Get back to us if you are stuck.

  6. #5
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,720
    Member #
    5580
    Liked
    718 times


    bfsog ...

    I have a program that I need written ... just kidding ...

    Very generous of you to provide a complete PHP/MySQL solution.
    Despite that it's for his site, it certain is something the rest of us can
    look at and learn from ... learning by example. Thanks!


  7. #6
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Thanks..

    I like to help people, I like to help even more if PHP is involved!

  8. #7
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,720
    Member #
    5580
    Liked
    718 times
    bfsog --
    .... yes, I found the white rabbit, but perhaps I should be looking for the brown one?


  9. #8
    Senior Member
    Join Date
    Aug 2003
    Location
    Melbourne, Australia
    Posts
    162
    Member #
    2563
    I don't think the script actually achieves what I want - althoguh I could just be misunderstanding it....

    I have an image on my site that shows the date of the next show of my band. Once that date as passed I need, or would like, the image to then rotate on to the next show coming up for which the image aready exists on our server. The script created seems to moreso be an image upload script?

  10. #9
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    No.

    The script is not an upload script. Like I said up there, I assume the images are uploaded already.

    What the script does is, it has code that reads from a table and displays an image, based on id

    So if on page1.php you wanted the second row's image to display, you would extract the second filename.

    Then, lets say, thgat date passes, you would manually have to log in and update the second row in the table to the new image.

    Clearer?

  11. #10
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,720
    Member #
    5580
    Liked
    718 times
    m.mckernan ...

    Would it be possible for you to name your images with
    a date, like this?

    i_061606.jpg
    i_070106.jpg

    Then, with a PHP script, it would simply load the image
    that is greater than one date and less than the next.

    So, say that ...
    the $date variable is "062006", so the PHP script would
    determine that the photo to display would be "i_061606.jpg".

    In your HTML code, you would insert the PHP script,
    <?php
    code here
    $date = blah blah
    $image = "./myimages/i_".$date.".jpg";
    ?>

    then, when you want to display the image, you would
    display it like this:

    <img src='<?=$image?>' alt='' />


    Is that what you mean?



Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:26 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com