Forum Moderators: coopster
Here is the string. srand ((double)microtime()*1000000);
It is supposed to rotate banners I have in seperate text files but I notice it doesn't work. That could be because of the reason you gave as I am sure I have everything set up properly. And the .txt files show on my page so I know that part works, it just is not rotating them, only rotating on onload.
Please tell me how long in time that is supposed to be and if most servers support something better than microtime. Thanks much! :)
so you get a random image each time you reload, this would be the expected behaviour as php is server side. Once the page is delivered to the user php has no more control over it until they make a new request to the server.
If you are trying to get images to rotate while the user sits on the same page then you should look at javascript, which is client side.
For instance lets say the javascript does the timer work, because thats what you are all saying javascript is the best for hour second and minute timers. The timers js code I can figure out on my own.
How would I call on the javascript function using php? By just using a php include command? Kind of thinking out loud here. Doesn't seem like that would work because to use the php include my page I am calling on has to be named something.php and javascript files end in .js. See what I am getting at? Not sure how you would use the two together. Just trying to learn something new here, hope someone knows a little bit about this to help me out. Thank you very much!
Php executes on the server and determines what is sent to the client (browser). Once sent, php is no longer involved unless you make another server request.
If you want to change something on a page after it is sent to the client without making another server request (a new page or AJAX-which is javascript anyway), then you have to use javascript.
So in a nutshell php runs on servers to do stuff, and javascript runs in browsers to do stuff. Something that also might be confusing you is that javascript is not java, which is an entirely different can of worms.
Hope this is useful.
Also, I was only trying to figure out how you use them together, because the above posts said that I could.
From what your saying though is in order to use them together for the timer issue, the javascript would have to call on the php not the other way around like I suggested.
But since php won't do hour, minute, second issues as stated above, would there be any reason at all to use them together in timer issues?
Knowing these things will clear up a lot!