prepare($myquery); $stmt->execute(); $count = $stmt->fetch(PDO::FETCH_NUM); $maxPages = ceil($count[0] / $pageSize); return $maxPages; //return $count; } //takes a db connection and a gallery id, retrieves from db //returns a nested associative array function getGallery ($conn, $startID, $pageSize) { $startHere = intval($startID); $theSize = intval($pageSize); $myquery = "SELECT id, thumb_uri, full_uri, title FROM galleryPhoto ORDER BY id DESC LIMIT " . $startHere . "," . $theSize; //echo $myquery; $gallery = array(); $stmt = $conn->prepare($myquery); $stmt->execute(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $gallery[] = $row; } return $gallery; } //retrieves updates, limit set by passed parameter function getUpdates ($conn, $limit) { $updates = array(); $stmt = $conn->prepare('SELECT id, title, content, DATE_FORMAT(dated, "%m-%d-%Y") FROM ranchUpdates ORDER BY dated DESC LIMIT '. $limit); //$stmt->bindParam('mylimit', $limit); $stmt->execute(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $updates[] = $row; } return $updates; } // end getUpdates //retrieve announcements based on id passed. function getAnnouncement ($conn, $id) { $announcement = array(); $stmt = $conn->prepare('SELECT * from announce WHERE id=:id'); $stmt->bindParam('id', $id); $stmt->execute(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $title = $row['title']; $content = $row['content']; $announcement['title'] = $title; $announcement['content'] = $content; } return $announcement; } // end of file: lib.php