From 758887b79c875b31b86d427e27f515e2c3d2a257 Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Sat, 21 Jul 2007 14:43:41 +0000 Subject: issue55, PHPFSPOT_IMG can now display a random selected photo git-svn-id: file:///var/lib/svn/phpfspot/trunk@232 fa6a889d-dae6-447d-9e79-4ba9a3039384 --- phpfspot.class.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'phpfspot.class.php') diff --git a/phpfspot.class.php b/phpfspot.class.php index 2df0250..ffb511d 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -1682,6 +1682,34 @@ class PHPFSPOT { if(isset($_SESSION['slideshow_img'])) unset($_SESSION['slideshow_img']); } // resetSlideShow() + + /*** + * get random photo + * + * this function will get all photos from the fspot + * database and randomly return ONE entry + * + * saddly there is yet no sqlite3 function which returns + * the bulk result in array, so we have to fill up our + * own here. + */ + public function get_random_photo() + { + $all = Array(); + + $result = $this->db->db_query(" + SELECT id + FROM photos + "); + + while($row = $this->db->db_fetch_object($result)) { + array_push($all, $row[0]); + } + + return array_rand($all); + + } // get_random_photo() + } ?> -- cgit v1.2.3-18-g5258