I am building a (simple...) webcomic page for a friend. I created a webadmin page, where he sets what text file goes online at a certain date. This is all connected to a MySQL database. For example, online_date would be set to 5902. Meaning, May 9th, 2002. Each entry has a number, $issue_id, and a colum called current. The way the sql is now, whenever it realizes that today that issue should go online, it sets current to 'y'. The next sql call calls the issue who's current is set to 'y'. Ok, this all works fine, IF there is a issue for every day. However, he wants to upload an issue once a week, or 3 times a week, however he feels. So... i need something that will load the last issue uploaded, not online_date = $current_date. Here is the code i have so far. How can i allow it to load the last issue set to go online? By the way, i cant use max_id, because he may upload issues in advance, and that would load them prematurely.
<?
$query = "SELECT issue_id, online_date from comic_issues WHERE online_date = $current_date ";
$result = mysql_query($query);
@extract(mysql_fetch_array($result));
$query = "UPDATE current_online SET issue_id = $issue_id AND online_date = $online_date WHERE colum_id = '1' ";
$result = mysql_query($query);
?>
<!-- ONLINE flag check. Here we find the comic issue entry that is market as
ONLINE. When we find it we take issue_id and assign it to $issue_id.-->
<!-- Here we do a mysql_query, and grab all of the info for the current comic.
We then take all of that info (which is returned to us in variables) and
give them real pathnames, as defined by sitewide.php.-->
<?
$query = "SELECT issue_id FROM current_online WHERE colum_id = '1' ";
$result = mysql_query($query);
@extract(mysql_fetch_array($result));
$arch_id = $issue_id;
$query = "SELECT issue_title, comic_image, first_rant, first_author,
second_rant, second_author
FROM comic_issues WHERE issue_id = $arch_id";
$result = mysql_query($query);
//Here will assign each returned field to its own $variable
@extract(mysql_fetch_array($result));
I dont really like this code that much, because it updates the database EVERY time the script is accessed, But it was the best thing I could come up with at the time. Thanks a bunch.
<?
$query = "SELECT issue_id, online_date from comic_issues WHERE online_date = $current_date ";
$result = mysql_query($query);
@extract(mysql_fetch_array($result));
$query = "UPDATE current_online SET issue_id = $issue_id AND online_date = $online_date WHERE colum_id = '1' ";
$result = mysql_query($query);
?>
<!-- ONLINE flag check. Here we find the comic issue entry that is market as
ONLINE. When we find it we take issue_id and assign it to $issue_id.-->
<!-- Here we do a mysql_query, and grab all of the info for the current comic.
We then take all of that info (which is returned to us in variables) and
give them real pathnames, as defined by sitewide.php.-->
<?
$query = "SELECT issue_id FROM current_online WHERE colum_id = '1' ";
$result = mysql_query($query);
@extract(mysql_fetch_array($result));
$arch_id = $issue_id;
$query = "SELECT issue_title, comic_image, first_rant, first_author,
second_rant, second_author
FROM comic_issues WHERE issue_id = $arch_id";
$result = mysql_query($query);
//Here will assign each returned field to its own $variable
@extract(mysql_fetch_array($result));
I dont really like this code that much, because it updates the database EVERY time the script is accessed, But it was the best thing I could come up with at the time. Thanks a bunch.