Banner rotation in php

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

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?

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!!

this method may help you

Add banners in database table and call them as randomly


$qry1="select * from banner_table ORDER BY RAND() LIMIT 0,1

it will display a different banner everytime user refresh the page

vineet

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

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.