Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

display random mysql record after every 8 seconds???

Guest
Aug 27, 2007 Aug 27, 2007
Looking to see if I could get some suggestions on how to achieve the following. I want to display the contents of random mysql records every 8 seconds but I am not sure how to code the every 8 seconds.

Any suggestions?
TOPICS
Server side applications
312
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 28, 2007 Aug 28, 2007
cdembek wrote:
> Looking to see if I could get some suggestions on how to achieve the following.
> I want to display the contents of random mysql records every 8 seconds but I am
> not sure how to code the every 8 seconds.

Apart from the fact that running a MySQL query every 8 seconds is likely
to use a lot of resources and probably result in an intensely annoying
web page, you are attempting something for which server-side programming
is not designed. A dynamic page using PHP (or any other server-side
language) is created by sending a request from the browser to the
server, where it queries the database, and sends back the result. So, to
do what you want, you need to send a new request every 8 seconds.

The only way to guarantee that it will work is to send a request for the
full page, using the refresh meta tag. This is extremely wasteful of
resources, and is likely to drive visitors mad, as the page rebuilds
seven times a minute. To rebuild just the part of the page that you want
to change, you would need to use Ajax or Flash.

A more sensible approach might be to send one query to the database, and
store a large number of results in an array. You could then use
JavaScript and DOM manipulation to select an element from the array at
random. However, like Ajax, this approach depends on JavaScript being
enabled in the browser. You would also need considerable scripting
skills to set it up.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 28, 2007 Aug 28, 2007
LATEST
Dave,

Thanks for you answer, I am still a newbie regarding coding (under 2 years) so I found your post very informative.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines