예제 #1
0
 public function askAction()
 {
     //include_once("connect.php");
     if ($_POST) {
         $content = $_POST['content'];
         $id = $_POST['UID'];
         $title = $_POST['title'];
         $abstract = substr($content, 0, 100);
         $nowtime = date('Y-m-d H:i:s');
         $tab = $_POST['tag'];
         //$tab = 'hahaha';
         $ask = new ask();
         $question = new question();
         $tag = new tag();
         $question_arr = array('QTitle' => $title, 'Qcontent' => $content, 'Qabstract' => $abstract, 'looknum' => 0);
         $qid = $question->insertQuestion($question_arr);
         $ask_arr = array('UID' => $id, 'QID' => $qid, 'time' => $nowtime);
         $ask->insertAsk($ask_arr);
         $tag_arr = array('QID' => $qid, 'tag' => $tab);
         $tag->insertTag($tag_arr);
         //$this->view->QID = $qid;
         echo $qid;
         //$this->render('questioned');
     }
 }
예제 #2
0
파일: quiz.php 프로젝트: aanabit/reactquiz
    } elseif (strpos($key, 'a_') > 2) {
        $index = intval(substr($key, 2, strpos($key, 'a_') - 2));
        $questions_tmp[$index]['values'][] = $value;
    } elseif (strpos($key, 'ck_') > 2) {
        $index = intval(substr($key, 2, strpos($key, 'a_') - 2));
        $questions_tmp[$index]['corrects'][] = $value;
    } elseif (strpos($key, 'q_') !== false) {
        $index = intval(substr($key, 2));
        $questions_tmp[$index]['before'] = $value;
    }
}
try {
    $dbo = new DBO($servername, $username, $password, $dbname);
    foreach ($questions_tmp as $key => $value) {
        $question = new question($key, $value);
        $question->insertQuestion($dbo);
    }
    $sql = "SELECT * FROM questions ORDER BY id LIMIT 1";
    $dbo->query($sql) or die($dbo->ShowError());
    while ($questionDB = $dbo->emaitza()) {
        $question = new question($questionDB);
        echo $question->render();
    }
} catch (PDOException $e) {
    echo $e->getMessage();
}
$conn = null;
?>
                        <input type="hidden" value="<?php 
echo $questions;
?>