$sql="SELECT p.photo_id, p.filename, p.description, c.camera_folder_name FROM photo p, photo_to_gallery ptg, camera c WHERE ptg.gallery_id=".$gallery["gallery_id"]." AND p.photo_id=ptg.photo_id AND p.public=1 AND c.camera_id = p.camera_id";
//handle exceptions for ordering the thumbnails
if ( ($gallery["gallery_id"] == 29) || ($gallery["gallery_id"] == 54) || ($gallery["gallery_id"] >= 57) ) {
$sql.= " ORDER BY photo_id";
} else {
$sql.=" ORDER BY p.filename, p.photo_id";
}
$res = mysql_query($sql,$my_conn);
$num_rows = mysql_num_rows($res);
while ($thumbs = mysql_fetch_object($res)) {
$thumbscount++;
//some filenames in the database include a leading "/". remove it.
if (substr($thumbs->filename, 0, 1) == "/") {
$thumbs->filename = substr($thumbs->filename, 1, (strlen($thumbs->filename)-1));
}
$output.='
filename.'" alt="'.str_replace('"','"', str_replace("'","'", $thumbs->description)).'" title="'.str_replace('"','"', str_replace("'","'", $thumbs->description)).'">';
}
echo $output;
?>