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..
-
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..
-
if (abc == 1) {
-
document.write("<\"Your 1. HTML-Banner-Code\">");
-
}
-