SJames Posted September 24, 2007 Share Posted September 24, 2007 I am writing the PHP for a website that makes weekly comics. They would like a feature where the comic can automatically be posted at a certain time and date, so they don't have to be up at midnight sunday nights to press "Post Comic". Is there a way to have the server run the script that posts the comic automatically or something that would allow the comic to be posted without human intervention? *I wont be able to post any code for you as I haven't written any, I am trying to see if this is feasible before I do anything. Quote Link to comment https://forums.phpfreaks.com/topic/70419-automation/ Share on other sites More sharing options...
HuggieBear Posted September 24, 2007 Share Posted September 24, 2007 I'd go for a database table with the comic strip details (including a datetime column to take the details of when the image should go live). In PHP I'd do a query like so... <?php // Get the current time in seconds from epoch $current_time = time(); // Run a query in the database $sql = "SELECT comic_image_path, unix_timestamp(go_live) AS gl_ts FROM comics WHERE gl_ts < $now ORDER BY gl_ts DESC LIMIT 1"; $res = mysql_query($sql) or die("Cant execute: $sql" . mysql_error()); $comic_path = mysql_result($res, 0, 0); // Output the comic echo "<img src='$comic_path'>\n"; ?> This way you could insert comic image details into the database with a future go_live date, and each time the page loads it would check if it's getting the latest 'live' image. I hope this makes sense. Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70419-automation/#findComment-353920 Share on other sites More sharing options...
rarebit Posted September 24, 2007 Share Posted September 24, 2007 mmm, with Huggies way, it would mean the comic is already uploaded and can therefore be checked (in situ) and previewed by privileged members! Quote Link to comment https://forums.phpfreaks.com/topic/70419-automation/#findComment-353928 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.