The simpler media website CMS
//connexion à la base mysql
$con = mysql_connect($host, $user, $pass);
mysql_select_db($db,$con);
//trouver la photo la plus recente
$query = "SELECT * FROM ".$db_prefix."images ORDER BY id DESC LIMIT 1;";
$result = mysql_query($query);
//trouver son almbum
$query2 = "SELECT * FROM ".$db_prefix."albums WHERE id=".mysql_result($result,0,'albumid').";";
$result2 = mysql_query($query2);
// construction de l'url de l'image
$image = mysql_result($result,0,'filename');
$album = mysql_result($result2,0,'folder');
$path = $base_url."/albums/".$album."/".$image;
//afficher l'image
return $path;
}
`
it's not perfect but it works and i hope a zenphoto guru will replace the ugly parts (mysql connexion) with the nice zenphoto adequate functions
in my template, i use:
`
" width="600"/>
`
i hope that will be useful to someone as zenphoto is useful to me. thx again guys
Comments
`
function getMostRecentPhotoURL() {
//trouver la photo la plus recente
//find the most recent photo
$query = "SELECT * FROM ".prefix("images")." ORDER BY id DESC LIMIT 1;";
$result = query($query);
//trouver son album
//find the corresponding album
$query2 = "SELECT * FROM ".prefix("albums")." WHERE id=".mysql_result($result,0,'albumid').";";
$result2 = query($query2);
//construction de l'url de l'image
//computing the image's url
$image = mysql_result($result,0,'filename');
$album = mysql_result($result2,0,'folder');
$path = FULLWEBPATH."/albums/".$album."/".$image;
//afficher l'image
return $path;
}
`
do you see more improvement? perhaps about the mysql_result() calls?
http://www.zenphoto.org/trac/wiki/ZenphotoHacks#LatestImagesCustomFunction
It seems to work very well.