SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Sep 2012
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    banner rotation in php

    hi, I am new to php can anyone help me in creating rotating banner in php.....

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Are you sure you don't want to use javascript for your rotating banners?
    What are you thinking of, to include a different banner every time the visitor refreshes the page?

  3. #3
    SitePoint Member
    Join Date
    Sep 2012
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes .. I want to strictly in php not using any other script....Well I want to display advertisement that include a different banner every time the visitor refreshes the page... Waiting for reply.. Please suggest for all other alternatives!!

  4. #4
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    622
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    this method may help you

    Add banners in database table and call them as randomly

    PHP Code:
    $qry1="select * from banner_table ORDER BY RAND() LIMIT 0,1 
    it will display a different banner everytime user refresh the page

    vineet

  5. #5
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    How do you want this to work:
    • Give it a directory and it picks a random image from that directory?
    • Store images paths in a database and pick one randomly?
    • Store images paths in a text file and pick one randomly?
    • Does the image have to have any meta-data associated with it (alt text, size, supplier reference etc)?

    You realise that if you have,say , 4 images to choose from "randomly" then you could conceivably return the same image 2 or more times in succession.

    Is that what you mean exactly, or do you mean "in turn", if you do mean "in turn" how do you decide which is the first one? If your webpage has 1000 hits and they all get the first image every time, then that wont be very "random" unless the "turn" is rotated.

    (one way round this is to number the images and then serve them by day of week, sunday you serve up 0.jpg, monday, 1.jpg and so on. Use the same trick to serve by the hour, or by the minute, or by the last digit of the timestamp (i.e. of 10) ... and so on.

    Do any of these links give you ideas
    PHP Code:
    random banner generator PHP 
    , come back and try and explain a little bit more about your particular situation and let us know what you tried and what did and did not work.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •