'' and is_live = 1 order by sort_key limit 1 "); } $photo = xone_row(" select * from ele_photos where is_live = 1 and post_key = '$post_key' and photo_key = '$photo_key' "); if (!$photo) die("bad photo"); foreach ($photo as $k=>$v) $post[$k] = $v; $photo = $post; xupdate(" update ele_photos set n_views = n_views + 1 where photo_key = '$photo[photo_key]' "); $prev = xone_row(" select * from ele_photos where post_key = '$post_key' and photo_thumb_url <> '' and sort_key < '$photo[sort_key]' and is_live = 1 order by sort_key desc limit 1"); if ($prev) { $photo["prev_photo_key"] = $prev["photo_key"]; $photo["prev_thumb_url"] = $prev["photo_thumb_url"]; } else { $photo["prev_photo_key"] = 0; $photo["prev_thumb_url"] = ""; } $next = xone_row(" select * from ele_photos where post_key = '$post_key' and photo_thumb_url <> '' and sort_key > '$photo[sort_key]' and is_live = 1 order by sort_key limit 1"); if ($next) { $photo["next_photo_key"] = $next["photo_key"]; $photo["next_thumb_url"] = $next["photo_thumb_url"]; } else { $photo["next_photo_key"] = 0; $photo["next_thumb_url"] = ""; } $gal = substr($site_url, 0, -1) . get_gallery_short_url($post); $photo["myspace"] = ""; $photo["comments"] = get_post_comments($post_key, $photo["photo_key"]); $photo["comments_cnt"] = count($photo["comments"]); display_template("photo.phtml", $photo); ?>