I am trying to create a dynamic naming convention using the id that a photo recieves when it is put into the database as part of a record.
The situation:
I have a form that I use to add a record (with a photo) to the database. Then this data is written to an html file. I currently name the html file as storyID.html. I do this by putting a query to the database before the data is added, asking for the next ID, knowing that will be the id of the story I am adding.
I want to be able to do this for my photos, but I cannot figure out how to implement this naming convention.
Let me show you how I have it setup for the html page, and where I am on the photo naming:
HTML page (which works fine):
function storyid()
{
$query = mysql_query("select max(id) as maxid FROM stories");
return (mysql_result($query,0,"maxid"))+1;
}
$storyfile = "/projects/sunarchive/htdocs/temp/sports/sports";
$fp = fopen($storyfile . storyid() . '.html','w');
if($fp)
{
fputs($fp,'<html><head><link rel=stylesheet href=../../main2.css type=text/css></head><body>');
fwrite($fp,chr(10));
fwrite($fp,'<TABLE WIDTH="440" border="0" cellspacing="0" cellpadding="10">');
fwrite($fp,chr(10));
etc
etc...
Where I am with the photo naming:
function photoid()
{
$query = mysql_query("select max(id) as maxid FROM stories");
return (mysql_result($query,0,"maxid"))+1;
}
if ($custom3_name == TRUE){
exec("cp $custom3 /tmp/$custom3_name");
$tmpimg = "/tmp/$custom3_name";
$newfile = "/projects/sunarchive/htdocs/image/";
$newphoto = "$newfile . photoid() . '.jpg'";
$new_w=140;
$new_h=191;
system("convert -quality 80 -antialias -sample '$new_wx$new_h' '$tmpimg' '$newphoto'");
unlink ($tmpimg);
}
elseif ($custom3_name == FALSE){
}