Jump to content

Automation


SJames

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/70419-automation/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/70419-automation/#findComment-353920
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.