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 20
  1. #1
    Member
    Join Date
    Sep 2006
    Posts
    77
    Member #
    14004
    Hello
    Anyone would have an idea how to change a table content (few lines of text plus one graphic) every time the page is visited? I wanted visitors to be welcome each time they come back to home page by a different message and a different picture.
    Thank you very much

  2.  

  3. #2
    Senior Member
    Join Date
    Apr 2005
    Location
    Hatfield, England
    Posts
    855
    Member #
    9790
    make the welcome message from javascript then create random script.

    Use the same script i showed you last time but just adapt it a bit so it displays text and not just a picture

    http://www.java-scripts.net/javascri...e-Script.phtml

  4. #3
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,693
    Member #
    5580
    Liked
    717 times
    You can use PHP.

    Your webpage would have the extension .php (index.php instead of index.html).

    Then, with PHP, you would read a text file that has a whole list of your images
    and a comment for each image.

    The PHP script could read a line randomly, or sequentially, or by date, etc.
    Changing with each page refresh, or with each day ...

    See this example of images changing randomly with each page refresh:
    http://www.pierreandclaudia.com

    Let us know how you want the content to change, and if you can/or will
    change your page extension to .php (index.php).

    Also, create a text file (using Notepad) that looks something like this:
    Caption and photo separated by "pipes" |

    Our place of business|our_company.jpg|
    Employee Photo|emp_photo.jpg|
    Another Caption Here|photo123.jpg|
    .
    .
    .


  5. #4
    Member
    Join Date
    Sep 2006
    Posts
    77
    Member #
    14004
    Hello
    Thank you for your answer.
    Unfortunately the script from http://www.java-scripts.net/javascri...e-Script.phtml will work only with pictures (the command is “random_imglink”).
    Mlseim please tell me how could I manage to do this effect with PHP? Is there any copy&past PHP script I could use? Is it a problem if my home page is in PHP and all others in html?

  6. #5
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,693
    Member #
    5580
    Liked
    717 times
    Only the page that is using PHP to display the image needs to be .php

    How do you want the pictures to change?
    With each refresh,
    change each day,
    ?


  7. #6
    Member
    Join Date
    Sep 2006
    Posts
    77
    Member #
    14004
    Hi Mlseim,
    I would like to change picture and few lines of the text, every time the page is reloaded.
    Thanks a lot

  8. #7
    Senior Member raspberryh's Avatar
    Join Date
    Aug 2004
    Location
    Erie, PA
    Posts
    882
    Member #
    7208
    Liked
    1 times
    Try making the following changes to that link that was posted by Perad (changes in red)...

    Code:
    <script language="JavaScript">
    <!--
    /*
    Random Image Link Script
    By Website Abstraction (http://www.wsabstract.com)
    and Java-scripts.net (http://www.java-scripts.net)
    */
    
    function random_imglink(){
      var myimages=new Array()
      //specify random images below. You can have as many as you wish
      myimages[1]="img1.gif"
      myimages[2]="img2.gif"
      myimages[3]="img3.gif"
    
      //specify corresponding links below
      var imagelinks=new Array()
      imagelinks[1]="http://www.wsabstract.com"
      imagelinks[2]="http://www.dynamicdrive.com"
      imagelinks[3]="http://www.java-scripts.net"
    
      var captions = new Array()
      captions[1] = "Javascript is cool";
      captions[2] = "PHP is cooler";
      captions[3] = "but Raspberryh is the coolest";
    
      var ry=Math.floor(Math.random()*myimages.length)
    
      if (ry==0)
         ry=1
         document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>' + captions[ry])
    }
    
      random_imglink()
    //-->
    </script>
    Or even BETTER, have a div for your caption, and do:
    Code:
     if (ry==0)
         ry=1
         document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')
         document.getElementById("caption").innerHTML = captions[ry];
    ...(and just make sure you include
    Code:
    id="caption"
    into your div tag)

    OR if you don't want a particular caption to be associated with an image (in other words, you want the caption to be random AND the image to be random SEPARATELY), then generate two different random numbers for each one, like this:

    Code:
      var ry=Math.floor(Math.random()*myimages.length)
      var rz=Math.floor(Math.random()*captions.length)
    
      if (ry==0)
         ry=1
      if (rz==0)
         rz=1
    
         document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')
         document.getElementById("caption").innerHTML = captions[rz];
    Heather
    choosy developers choose gif!
    website | paintings | blog

  9. #8
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,693
    Member #
    5580
    Liked
    717 times
    OK,

    So you have your text file like this (saved as "photos.txt" ):

    Our place of business|our_company.jpg|
    Employee Photo|emp_photo.jpg|
    Another Caption Here|photo123.jpg|


    Then, you need to put this PHP script at the very
    top of your web page (index.php):

    <?php
    $pickline = file("photos.txt");
    shuffle($pickline);
    list ($caption, $photo) = split ('\|', $pickline[0]);
    ?>

    Then, wherever you need the photo and caption do this:
    (however you have your <table> or <div> ) ....

    <table>
    <tr><td><img src="<?=$photo?>"><br><?=$caption?></td></tr>
    </table>


  10. #9
    Member
    Join Date
    Sep 2006
    Posts
    77
    Member #
    14004
    Hello
    Thank you everyone for helping.
    Melseim I tried your suggestion, I hoped that was the simplest one. But couldn’t edit it on the web site (netdirms are not supporting php) :-(
    Then I turned to Raspberryh’s solution, but it is not working either.
    Could you please have a look at the code?

    http://www.sample332uk-00027-hp.com/index.html

  11. #10
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,693
    Member #
    5580
    Liked
    717 times
    That's a bummer!

    I suggest you do this:

    Go to this webhost: http://www.cleverdot.com

    and purchase the $29.99 plan for an ad-free site WITH your own domain name!

    That's really cheap. You can hardly NOT take an offer like that.

    They offer everything you need (PHP, MySQL, etc.)

    I've also used Netfirms, and although they are good, Cleverdot is cheaper and I've
    never had any problems with them either.

    ============

    You must use PHP, not just for solving your problem, but for future dynamic
    page generation, content management and other powerful things.

    Spend the money and have fun playing around ... you won't regret it!



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 10:48 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com