Try to build where array
$where = array();
if ((int) $studentID >0) {
$where[] = " studentID = '{$studentID}' ";
}
if ((int) $QuestionId >0) {
$where[] = " QuestionId = '{$QuestionId }' ";
}
and at end implode $where by AND statment
if (!empty($where))
$query['where'] = ' WHERE '. implode(' AND ', $where);
It's only a way. I did not debug this code.