Exemplo n.º 1
0
 /**
  *  gets all answers for the the given qid
  */
 public static function _get_all_answer_by_qid($ref_qid)
 {
     $all_answers = array();
     $connection = _database::get_connection();
     $query = "SELECT * FROM `_answers` WHERE `_a_qid` = {$ref_qid} ORDER BY `_a_time` DESC";
     if ($res = $connection->query($query)) {
         $i = 0;
         while ($arr = $res->fetch_array()) {
             $obj = new _answers();
             $obj->setAid($arr['_aid']);
             $obj->setDescription($arr['_description']);
             $obj->setAUid($arr['_a_uid']);
             $obj->setAQid($arr['_a_qid']);
             $obj->setApt($arr['_apt']);
             $obj->setNotApt($arr['_notapt']);
             $obj->setATime($arr['_a_time']);
             $all_answers[$i] = $obj;
             $i++;
         }
         return $all_answers;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
<?php

/**
 * sagarpatel
 * Date: 03-Apr-15
 * Time: 3:55 PM
 */
include_once 'utils/utils.php';
include_once 'classes/_answers.php';
session_start();
if (isset($_POST['ad']) && isset($_POST['qid']) && isset($_SESSION['uid'])) {
    $ad = cleanString($_POST['ad']);
    $qid = $_POST['qid'];
    $uid = $_SESSION['uid'];
    if (strlen($ad) != 0) {
        $ans = new _answers();
        $ans->setDescription($ad);
        $ans->setAQid($qid);
        $ans->setAUid($uid);
        if ($ans->_insert_db()) {
            header("Location: ../index.php");
        } else {
            header("Location: ../index.php");
        }
        die;
    }
    setcookie('fonas', 1, time() + 3);
    header("Location: ../index.php");
    die;
}