Time to pull out of database

Hi just a what is your opinion on recommendation question. I need a timer for pulling my items out of my mysql database. So that there isn’t web page movement when I pull something out every so many seconds. Is it easiest to find a way to do that with ajax, or is there a way that is easier than that. Please let me know thanks a lot.

Crontab is the standard task scheduler in linux. You can create a task (“cron job”) to run every minute, or however often you need. That task can be executing a PHP script.

Why do you need to pull things out of the database if nobody is using the website? If you can describe the actual situation, there might be a better way of doing it.

Thank you very much for some of your expert opinions on this. Isn’t that server side and would cause the page to refresh, …so that would cause page movement in bigger web pages. Let me know if that doesn’t cause web pages to refresh or page movement in bigger web pages when the timer goes off again. Also it needs to work like people need no matter what worldwide browser someone is looking at my web page with. It’s because I’m pulling something out of my mysql database and visitors need to see it change every so many seconds when they are looking at my web page. So I’m pulling 4 images out of database every 15 or less seconds, then 15 more seconds pulling out 4 more to replace the last and continues. I already know how to do that, I just need a timer to connect to my php. So that it pulls things out of my database so there is no page movement, to any visitors looking at my web page when things change. So I needed to know the type that is easiest to put together that I can figure out how to connect to a php script, that pulls things out of my database.

I don’t understand.

Having the images on the page change every 15 seconds for people viewing the page is simple. You have a JavaScript interval make an AJAX request every 15 seconds for 4 new images.

Why does anything need to happen server-side every 15 seconds?

Thank you.

Maybe where the hang up is I forgot to say I need the things pulled from my database to be searched by search engines. So I can’t have my php wrapped in javascript, because then the changing database items can’t be searched by search engines. Also if something makes the page refresh every time the timer goes of that’s bad also because there is page movement every time the timer goes off.

So that why I said the first ones, I need things changing from my database every so many seconds so it is smooth, and also so the data pulled is still searched by search engines. Others told me ajax could probably do that before but I wanted to make sure that is the easiest one to do that with before I get started in trying to figure it out.

You don’t need to change anything in the database or have any timers. You’re approaching the problem wrong.

You need to decide what to display when a request comes in (from a user, from a search spider, it’s all the same) based on the current time.

If something’s supposed to increase by 1 every 15 seconds, and its value was 1 at 2:00PM, and it’s now 4:00PM… you do not have to run any kind of timers or change anything in the database. Your code just says “hey, it’s now 4:00, the time in the DB is 2:00, 2 hours * 60 minutes * 4 updates per minute = the value is now 480”.

eBay auctions display a different “time left” every time you view the page. There is no program/timer running changing a “time left” counter at eBay. They’re just displaying “auction end time (unchanging data that gets stored) minus current time” at each request.

Dan are you messing with my head on purpose are u reading what I’m saying lol? It sounds like youre not even reading what I’m saying. I am pulling 4 items from a mysql databse with my php. On a next call to the mysql database it pulls out 4 more to replace the last 4 and continues. Pulling them out onto my web page when visitors are looking at my page. I know how to do all that just said, but then I need that happening every 15 seconds, and visitors see that happening when the web page is still open. So that search engines can still read the database pulled content. Maybe if read from beginning again will see this is what I am discussing.

So why are you changing the time to something else than what I said, why does it sound like you’re trying to do something else and for different seconds etc. than what I am even needing? You have me all confused because doesn’t sound like you’re hearing anything I’m saying. Hope someone can help, thank you very much Dan and anyone that can help me with my questions.

I’m reading what you’re saying. How does this jive with your search engine requirement? The search engine will not be on your page for 15 seconds. It will just make one HTTP request. You serve it 4 images. You can’t serve it 4 more every 15 seconds. It can’t index all the images if you only have one page that displays 4 at a time at a single URL; the search engines keep 1 copy of the content at any unique URL.

Ok I see what I stumped about. I’m not saying at all that I want the search engines to catch all items when they are pulled out. Only so that whatever happens to be on the page when a search engines does its little search it can read it. You know, just so that search engines can even see what it happens to be at the time. In other words I don’t want to use any code for a timer, that is going to block the search engines ability to read what happens to be pulled out at the time. Also I’ll be having a timer that I can adjust the time on, so sometimes I might have it going for more seconds timer or less. I was trying to ask what kind of code I should use for a timer, that won’t block search engines ability to read the pulled items when they pass. Also that doesn’t cause a whole page refresh to make the page move when the seconds timer goes off again. No the search engines do not have to catch all the data I didn’t need that, only so the search engines have access to the pulled data. Thank you very much.

Search engines dont sit around on your page and wait. They scan, and move on. Your content is whatever comes up in the first page pull, and they often skip all javascript. (Though i think that habit has decreased over time. Could be wrong.)

I just said I know search engines don’t do that, I don’t need them searching all pulled data. I said the whole time only so the data pulled is searchable whenever they pass. That’s not even my issue anyway I said. Well you can read what I said first posts, wanted to know what code is best for pulling from mysql, without blocking my php, that pulls that data for search engines to see only when they pass. Hope someone can tell me what that is, other said use ajax but I didn’t know if that was the easiest one to piece together or not since I’m not an expert at coding.

Create a PHP page that displays 4 images at random, then, use an AJAX call (possibly via jQuery) to obtain another 4 images. Doing it this way means that search engines will get a regular HTML page to index, but your users will be served another set of images; after a predetermined interval.

Make sense?

Thanks a lot Anthony for getting to me for that sometimes I’m pulling text too not just images. Are you saying the search engines can still search my pulled data on the web page with some Ajax similar to what you just mentioned? Please let me know thank you very much.

1Jen, as mentioned the search robot will not be on your page after 15 seconds. So it doesn’t matter whether you refresh that content by a meta page reload, Ajax, voodoo magic, or throwing a coin into a fountain and thinking of unicorns. The search bots ability to parse JS is irrelevant, because it’ll be on a SetInterval(15000), and they won’t wait that long.

So your PHP page will serve 4 initial images and text, and that’s what the search engines will index. Users with JS and who hang around for 15 seconds will have the replacement content dropped in.

I don’t think that too much fair, it does matter in a pretty big way whole reason I’m asking. Since if I use a timer to reload the PHP script to pull out the mysql data, and the timer I use to pull that out of the database without page movement stops the search engines from reading any of the pulled out text, then I’m sunk :/. I need a timer to pull our the database data without page movement, that usual page refreshes cause. The search engines can still read my text that is pulled out part of the time when they pass. Since I shouldn’t use something where there is no ability for any passing search engines to even scan some of it. Some of you probably know what I’m talking about, for instance, the other usual client sides and server sides cause problems in those, so was asking if Ajax will help me with that or something else… I mean I can’t dig into Ajax since not good at it anyway have never touched Ajax myself, if it has no ability to even do that at all anyway, and if I should be using something else completely instead. Someone that knows what I’m saying, there must be someone that can answer this question I’ve been asking. If Ajax can help with that or not, or something else instead thanksa whole lot.

The original page will be constructed by PHP pulling data from MySQL and rendering the HTML page. This is what the search engines will see. They will request the page once, and whatever the initial content is, that’s what they’ll use for indexing. No JavaScript required for this step.

The only way to replace content on the page after 15 seconds, without reloading the page, is to use JavaScript. You’d do an Ajax get request to get replacement HTML and replace the innerHTML of an element on your page with that new content.

Using JS like this will not prevent search engines from indexing the original content. The search engines will get the same result as a user with JS turned off.

Search Engines ability or inability to parse JS is irrelevant in this case, because of the 15 second delay. As we’ve said they don’t spend time on the page for that event to occur. Now if you were using JS to write the initial content in the first place that would be a problem. But you’re not. The initial content will be set in the markup, built by PHP. Only the replacement content will be performed by Ajax.


There is one way. Sort of.

Load all the data into hidden DIV’s, and use javascript to display/hide them on the timed rotation.

It is not desired behavior, it is not good design (because users will have to download ALL of the images and text, regardless of whether or not they actually end up seeing them), but it would -potentially- get read by the search engine. Whether or not the search engine reads non-displayed div’s is in the code of the engine, and not something the world is generally privvy to…

Thanks a whole lot you two that’s the kind of opinion I needed :). I’ll probably be back later asking you some more questions about that privately will probably work best. What I was a bit confused on and probably doesn’t matter is our differences on the search engines part. I thought all the different search engines came and went at their own will. Just whenever they happened to be on a page without any rhyme nor reason to it, except for their own pre-programmed designed rythms for when they are set to search internet pages, where, and why. Am I getting there is more deliberation than that and there are certain times they are more likely to search internet web pages then others? In any case, thank you very much again really appreciated your getting back to me on the other.

No, there’s no time they are more likely to be on your site than others. Each search engine has its own spiders and its own policies for how often pages are re-crawled.

How often Google returns to your site and how deeply it crawls depend on the presence of and directives in your sitemap file, the PageRank of the root of your domain, and how often it has detected fresh content when crawling your site in the past.

This forum is being crawled by search spiders constantly, 24 hours a day, because of sitepoint.com’s high PageRank and the crawlers finding new content each time they return. StarLion’s last post above yours is already in Google, you can search for text from it and find this page.

Most small sites are only revisited every few days to weeks. It’s completely different for every website.

Thanks a lot Dan that was stuff good to know.

StarLion’s last post above yours is already in Google


How often Google returns to your site and how deeply it crawls depend on the presence of and directives in your sitemap file, the PageRank of the root of your domain, and how often it has detected fresh content when crawling your site in the past.
More very helpful. That explains why Google hasn’t been searching as often, I haven’t been working on my pages as often bad economy you know, trying to get back to pages that really needed help long ago again.