random table header images ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pagekeeper
    New Member
    • Feb 2004
    • 7

    random table header images ?

    is it possible to randomise the colors/images that appear in the table header ?

    if so how can i do that ?

    thanks in advance
  • Jake Bunce
    Senior Member
    • Dec 2000
    • 46598
    • 3.6.x

    #2
    PHP has a rand() function.

    You can use code like this in the phpinclude_start template to generate a random number

    Code:
    $ran_num = rand(5, 15);
    In this case the number is between 5 and 15. Then somehow use that number when you call your colors / images by using this variable in the templates:

    Code:
    $ran_num

    Comment

    • pagekeeper
      New Member
      • Feb 2004
      • 7

      #3
      hmmm, cool that its possible, i still dont understand step by step would be great

      i keep the images i use in the images/misc folder .....

      there isnt a way to do that with css is there ?

      Comment

      • Jake Bunce
        Senior Member
        • Dec 2000
        • 46598
        • 3.6.x

        #4
        For example, if you have 5 random images that you want to display at the top of your forum, and those images are uploaded to the images/misc directory under these names:

        1.gif
        2.gif
        3.gif
        4.gif
        5.gif


        Then you can randomize their appearance by adding this code to your phpinclude_start template:

        Code:
        $ran_num = rand(1, 5);
        And this code to your header template:

        Code:
        <img src="images/misc/$ran_num.gif" alt="" border="0" />
        That should work.

        Comment

        • pagekeeper
          New Member
          • Feb 2004
          • 7

          #5
          i added <td background="$stylevar[imgdir_misc]/$ran_num.gif" colspan="2"> and adding the string to the phpinclude_start but it returns <td background="images/misc/.gif" colspan="2"> with no random number ....

          Comment

          • Jake Bunce
            Senior Member
            • Dec 2000
            • 46598
            • 3.6.x

            #6
            Can you post the contents of your phpinclude_start template?

            Comment

            • pagekeeper
              New Member
              • Feb 2004
              • 7

              #7
              // Example of how to include a seperate file:
              // ob_start();
              // require("yourheader.html");
              // $header = ob_get_contents();
              // $ran_num = rand(1, 5);
              // ob_end_clean();

              - this is what was in it .... except i added that line ....
              Last edited by pagekeeper; Sat 30 Oct '04, 4:12pm.

              Comment

              • Jake Bunce
                Senior Member
                • Dec 2000
                • 46598
                • 3.6.x

                #8
                A "//" means that line is commented out.

                Replace the entire contents of that template with just this:

                Code:
                $ran_num = rand(1, 5);

                Comment

                widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                Working...