I’d like to have a php page that will retrieve the 10 most recent articles submitted to a database and create a static html page with the results from the query.

The idea is to reduce the load on my mysql db by only hitting the db once instead of hitting it every time a visitor views the page. I’d like to use a cron job to run the php page / script at a scheduled time.

The querying of the database I can do, but how to code the generation of the html page is quite frankly beyond me

Any ideas on how to do this would be most welcome

Thanks

Recommended Answers

All 2 Replies

So you are gonna use a CRON job to query a db at certain intervals that will then create a static html that you can include on other pages?

You just need to do the DB query then use PHP's File functions to create a new file then parse the DB results in to whatever format you require. e.g XML

eg.
$res=mysql_query("...");
$f=fopen("db.html","w");
...fetching data
fwrite($f,"Data: ".$data."\n");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.