public function getRandQuestion($level, $Subject) { $pdo = Database::getDB(); $stmt = $pdo->prepare("SELECT * FROM brain_Question WHERE level = ? AND subject = ? ORDER BY Rand() LIMIT 5"); $stmt->execute(array($level, $Subject)); $result = $stmt->fetchAll(); $brain_RQuestions = array(); foreach ($result as $row) { $brain_Question = new brain_Question(); $brain_Question->setQid($row['bid']); $brain_Question->setLevel($row['level']); $brain_Question->setSubject($row['subject']); $brain_RQuestions[] = $brain_Question; } return $brain_RQuestions; }