function updatePassword() { $st_user = $_POST['st_user']; $st_pwd = $_POST['st_pwd']; $db = new DB_Connect(); $statement = "update students set s_pwd=? where s_user=?"; $result = $db->prepare($statement); $result->execute(array(md5($st_pwd), $st_user)); echo json_encode(array('success' => $result->rowCount())); }
public function __construct($s_user) { $db = new DB_Connect(); $column = 'a.s_user, a.s_num, a.s_pwd, a.s_name, a.s_mail, a.s_phone, a.s_date, a.test_type_id, d.dept_name, d.id dept_id, c.major_name, c.id major_id, b.class_name, b.id class_id, a.score_1, a.score_2, a.score_3, a.score_ans, a.score_type, a.reg_date, a.s_role, e.edu_name, e.edu_id '; $from_clause = 'from students a left join classes b on a.class_id=b.id left join majors c on b.major_id=c.id left join departments d on c.department_id=d.id left join educations e on a.edu_id= e.edu_id '; $where_clause = 'where a.state=1 and a.s_user=:s_user'; $statement = 'select ' . $column . $from_clause . $where_clause; $result = $db->prepare($statement); $result->execute(array(':s_user' => $s_user)); if ($row = $result->fetch()) { $this->s_user = $row['s_user']; $this->s_num = $row['s_num']; $this->s_pwd = $row['s_pwd']; $this->s_name = $row['s_name']; $this->s_mail = $row['s_mail']; $this->s_date = $row['s_date']; $this->dept_name = $row['dept_name']; $this->major_name = $row['major_name']; $this->class_name = $row['class_name']; $this->score_1 = $row['score_1']; $this->score_2 = $row['score_2']; $this->score_3 = $row['score_3']; $this->score_ans = $row['score_ans']; $this->score_type = $row['score_type']; $this->reg_date = $row['reg_date']; $this->s_role = $row['s_role']; $this->edu_name = $row['edu_name']; $this->s_phone = $row['s_phone']; $this->dept_id = $row['dept_id']; $this->major_id = $row['major_id']; $this->class_id = $row['class_id']; $this->edu_id = $row['edu_id']; $this->test_type_id = $row['test_type_id']; } else { } }
function Register() { $birth = (string) $_POST['st_birth']; $birth = substr($birth, 6, 4) . '-' . substr($birth, 0, 2) . '-' . substr($birth, 3, 2); $param = array(':st_user' => (string) $_POST['st_user'], ':st_pwd' => md5((string) $_POST['st_pwd']), ':st_name' => (string) $_POST['st_name'], ':st_no' => (string) $_POST['st_no'], ':st_mail' => (string) $_POST['st_mail'], ':st_depart' => (string) $_POST['st_depart'], ':st_major' => (string) $_POST['st_major'], ':st_class' => (string) $_POST['st_class'], ':st_grade' => (string) $_POST['st_grade'], ':st_birth' => $birth, ':reg_date' => date('y-m-d', time()), ':st_edu' => intval($_POST['st_edu'])); $db = new DB_Connect(); $column = 's_user, s_num, s_pwd, dept_id, s_name, s_mail, s_date, class_id, major_id, reg_date, edu_id, s_grade'; $statement = 'insert into student(' . $column . ') values(:st_user,:st_no,:st_pwd,:st_depart,:st_name,:st_mail,:st_birth, :st_class,:st_major,:reg_date,:st_edu,:st_grade)'; $result = $db->prepare($statement); $result->execute($param); echo json_encode(array('flag' => $result->rowCount())); }
$testBox[$i] = new KoolListBox("testBox_" . $i); $testBox[$i]->id = "testBox_{$i}"; } // <div style='clear:both'></div> foreach ($testBox as $box) { $box->AllowTransferOnDoubleClick = true; $box->Width = "300px"; $box->Height = "490px"; $box->styleFolder = "default"; $box->AllowMultiSelect = true; } $testBox[$s_role]->TransferToId = "testBox_{$s_role_to}"; $testBox[$s_role]->ButtonSettings->ShowTransfer = true; $testBox[$s_role]->ButtonSettings->ShowTransferAll = true; $db = new DB_Connect(); $sth = $db->prepare($sel); $sth->execute(); while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { $role = (int) $row['s_role']; $item = new ListBoxItem(); $item->Data = array("s_name" => $row['s_name'], "s_num" => $row['s_num'], "s_id" => $row['s_id']); $testBox[$role]->AddItem($item); } foreach ($testBox as $box) { $box->ItemTemplate = "<div class='student_list_item' id='{s_id}'>姓名:<strong>{s_name}</strong><label id='noLabel'>学号:<strong>{s_num}</strong></label></div>"; $box->Init(); echo "<div style='padding:20px;float:left;'>"; echo $box->Render(); echo "</div>"; } echo "<button id='assignSure' >确定分配</button>";
function getMessageTypeToSelect() { $db = new DB_Connect(); $statement = "select * from information_types"; $result = $db->prepare($statement); $result->execute(); $first = 1; $ret = ""; while ($row = $result->fetch()) { $ret = $ret . "<option value='" . $row['id'] . "'>" . $row['name'] . "</option>"; } echo json_encode(array('content' => $ret)); }
function Register() { $birth = (string) $_POST['st_birth']; //$birth = substr($birth,6,4).'-'.substr($birth,0,2).'-'.substr($birth,3,2); $param = array($_POST['st_user'], $_POST['st_no'], md5($_POST['st_pwd']), $_POST['st_name'], $_POST['st_mail'], $_POST['st_phone'], $birth, $_POST['st_class'], date('y-m-d', time()), intval($_POST['st_edu']), $_POST['st_grade']); $db = new DB_Connect(); $column = 's_user, s_num, s_pwd, s_name, s_mail, s_phone, s_date, class_id, reg_date, edu_id, s_grade'; $statement = 'insert into students(' . $column . ') values(?,?,?,?,?,?,?,?,?,?,?)'; $result = $db->prepare($statement); $result->execute($param); echo json_encode(array('flag' => $result->rowCount())); }
public function getRandAns($test_type_id = -1, $que_of_num = 60) { $sql = "select * from question where q_type=2 "; if ($test_type_id != -1) { $sql .= " and test_type_id={$test_type_id}"; } $sth = parent::prepare($sql); $sth->execute(); $res_all = $sth->fetchAll(); $res_rand = array(); $pid_num = count($res_all); $temp = array(); if ($pid_num < $que_of_num) { $que_of_num = $pid_num; } for ($i = 0; $i < $que_of_num; $i++) { $rand_num = rand(0, $pid_num - $i - 1); $res_rand[$i] = $res_all[$rand_num]; $temp = $res_all[$rand_num]; $res_all[$rand_num] = $res_all[$pid_num - $i - 1]; $res_all[$pid_num - $i - 1] = $temp; } return $res_rand; }
<?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ require_once '../../private/class/SMT.php'; require_once '../../private/class/DB_Connect.php'; $con = new DB_Connect(); $admin_info = array(); session_start(); if (!array_key_exists("dxU1", $_SESSION)) { // $_SESSION["dxU1"] = "qwe123"; // } $query = 'select info_id,title,info_date from info_board where state = 1'; if ($stmt = $con->prepare($query)) { $stmt->execute(); $info = $stmt->fetchAll(PDO::FETCH_ASSOC); } $smt = new SMT('adminInfo'); $smt->render(array('title' => '公告通知', 'adminInfo' => $info));
$kcb->scriptFolder = $KoolControlsFolder . "/KoolComboBox"; $kcb->styleFolder = "default"; $kcb->width = "185px"; $kcb->additem('年', 'n', NULL, $selected_id == 'n'); $kcb->additem('月', 'y', NULL, $selected_id == 'y'); switch ($selected_id) { case 'n': $format = '%X'; break; case 'y': $format = '%X-%c'; break; } $db = new DB_Connect(); $query = "select DATE_FORMAT(reg_date,'" . $format . "') date,count(*) from student group by (date)"; if ($stmt = $db->prepare($query)) { $stmt->execute(); $date = $stmt->fetchAll(PDO::FETCH_NUM | PDO::FETCH_COLUMN, 0); $stmt->execute(); $count = $stmt->fetchAll(PDO::FETCH_NUM | PDO::FETCH_COLUMN, 1); } //echo $query.'<br/>'; //var_dump($date); //var_dump($count); for ($i = 0; $i < count($count); $i++) { $count[$i] = (int) $count[$i]; } $chart = new KoolChart("chart"); $chart->scriptFolder = $KoolControlsFolder . "/KoolChart"; $chart->Title->Text = "注册统计"; $chart->Width = 1280;