Announcement

Collapse
No announcement yet.

random table header images ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #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


    • #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


      • #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


        • #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


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

            Comment


            • #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 30th Oct '04, 5:12pm.

              Comment


              • #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...
                X