How to rotate top page banner using php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vssp
    Contributor
    • Jul 2006
    • 268

    How to rotate top page banner using php

    Hai friends,


    I am very confused this task. please help me.
    if five banners are stored in one location , I want to displayall the banners simultaniously in my application.

    How to rotate the webpage top banner ? In my application i am getting the immage details using database.

    Please send me any idea.
    _______________ ___
    Thanks
    Vssp
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Hi there,

    am not PHP expert, but have created banner rotation script using ASP.. well.. i assume the logic is always same..

    the question is do you need to show those banners in random order or u need to show them in sequence?

    kindly follow the steps below and it should work fine..

    1st step design / re-design your table structure as below..

    id | fldPath | fldDetails | fldWidth | fldHeight | fldxyz

    make sure the (id) is of numeric datatype as well as autonumber is set to be true..

    2nd step..

    write a simple function to generate numbers based on the total records found in your table..

    let say, you have a total of 5 banner details in your database, make sure the random number generated must be within 1 and 5.. hope you get what i mean..

    3rd step..
    let assume, number 3 is generated by your random number function.. run SQL query to pick banner details whose (id) is 3 as well..

    function to generate random number..
    Code:
    function randInt(min,max)
    {
         var div = (max - min) + 1
         var randNum = Math.random()
         for (var i = 0; i <= div - 1; i++)
         {
              if (randNum >= i / div && randNum < (i+1) / div)
              {return i + min}
         }
    }
    var abc = randInt(1,5);
    show the banner using javascript based on randomly generated number..
    Code:
    if (abc == 1) {
         document.write("<\"Your 1. HTML-Banner-Code\">");
    }

    Comment

    • vssp
      Contributor
      • Jul 2006
      • 268

      #3
      Thanks for your repaly

      Comment

      • sashi
        Recognized Expert Top Contributor
        • Jun 2006
        • 1749

        #4
        Hi VSSP,

        anytime buddy.. hope the guide provided on my previous post helped you to get started with.. take care ny fren.. :)

        Comment

        Working...