<?php /** * User: Sagar * Date: 03-Apr-15 * Time: 11:01 AM */ include_once 'classes/_answers.php'; session_start(); if (isset($_POST['aid'])) { $aid = $_POST['aid']; $uid = $_SESSION['uid']; $ans = _answers::_chng_apt($aid, $uid); if ($ans != null) { echo $ans->getApt(); } else { echo 'err'; } } else { echo 'err'; }
?> </a> on <?php echo $q->getQTime(); ?> </span> </div> </div> <div class="answer-slider">double click to see answer(s)</div> <div class="answer"> <?php $ansarr = _answers::_get_all_answer_by_qid($q->getQid()); $ans = new _answers(); if (count($ansarr) == 0) { echo "Sorry No Answers Yet!!"; } foreach ($ansarr as $ans) { ?> <div class="answer-description"> <table class="Q-aligner"> <tr> <td>A: </td> <td><?php echo $ans->getDescription(); ?> </td> </tr> </table>
/** * 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; } }
<?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; }