|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
Rand() banner display
I have wrote a little random banner script, for some reason, it doesn't seem to display, there are not errors, and I tried out the sql query in phpmyadmin and it works fine
php Code:
|
|
#2
|
|||
|
|||
|
RE: Rand() banner display
forget what I have just wrote, should of selected * instead on id
|
|
#3
|
|||
|
|||
|
RE: Rand() banner display
Just two potential problems... Are you sure that your path to the images is correct? Also, what's up with the curly brackets after the fetch array?
|
|
#4
|
|||
|
|||
|
RE: Rand() banner display
Oh, yeah. That too.
|
|
#5
|
|||
|
|||
|
RE: Rand() banner display
I've had some problems with rand().
on some os, the number was displayed as 4343242, and on others 432432e24 (or something). Be aware of this if you need an real number. I used round($i, 10) to correct this problem. worked fine... |
|
#6
|
|||
|
|||
|
RE: Rand() banner display
kohaar, the php rand() function isnt what he was referring to i dont think, as you cant generate a random image through that function...i dont think. if you can i would like it hear it
he was talkin bout the SQL rand() function |
|
#7
|
|||
|
|||
|
RE: Rand() banner display
Sorry... I have no idea on how the php db functions work (haven't got around to install sql on my server)
|
|
#8
|
|||
|
|||
|
RE: Rand() banner display
Russ,
I just wanted to add that I think your code was better when you had 'id' instead of * (I know you need more than 'id' for your code to work - I am suggesting you type the column names out for your queries instead of using *). Cheers, Keith. |
|
#9
|
|||
|
|||
|
RE: Rand() banner display
so if I has something like this?
SELECT id name link picname FROM bannerdb ORDER BY rand() LIMIT 1 |
|
#10
|
|||||
|
|||||
|
RE: Rand() banner display
Yeah, but you need commas between the column names...
php Code:
Cheers, Keith. |
|
#11
|
|||
|
|||
|
RE: Rand() banner display
You also need to seed the random number generator using srand, see
http://www.php.net/manual/en/function.srand.php |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Rand() banner display |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|