/** * * @param string $where * @return array 返回数据库查询后的数组: */ function pagination($where, $conn, $tbl_name) { require_once 'class/Config_commodity.php'; require_once 'class/DBpagination.php'; require_once 'class/DBcount.php'; require_once 'class/Info_user.php'; require_once 'class/Config_user.php'; require_once 'Include_picture.php'; //2.向数据库查询符合条件数,以计算显示分页数目 $dbcount = new DBcount($tbl_name, $where); $retval = $dbcount->excute($conn); $row = mysqli_fetch_array($retval, MYSQLI_NUM); $count = 1 + (int) (($row ? $row[0] : 0) / SIZE_EACH_PAGE); //3.计算当前页码; $page = isset($_GET['page']) ? (int) $_GET['page'] : 1; $page = $page > $count ? $count : $page; //4. 查询当前页的数据 $choosed_fields = array(Config_commodity::table_name . '.' . Config_commodity::description, Config_commodity::table_name . '.' . Config_commodity::id, Config_commodity::table_name . '.' . Config_commodity::publisher, Config_commodity::table_name . '.' . Config_commodity::title, Config_commodity::table_name . '.' . Config_commodity::price, Config_commodity::table_name . '.' . Config_commodity::release_date, Config_commodity::table_name . '.' . Config_commodity::praise, Config_commodity::table_name . '.' . Config_commodity::leave_message_time, Config_commodity::table_name . '.' . Config_commodity::id); $DBpagination = new DBpagination($tbl_name, $where, $page, SIZE_EACH_PAGE, $choosed_fields); $reval = $DBpagination->excute($conn); //逐个配置 array 三级关联数组 供界面使用 $array = array(); while (($temp_database_row_array = mysqli_fetch_array($reval, MYSQLI_ASSOC)) != null) { $userinfo = Info_user::get_user_info_by_id($conn, $temp_database_row_array[Config_commodity::publisher]); $array[] = array('imgs' => get_commodity_pic($conn, $temp_database_row_array[Config_commodity::id]), 'description' => $temp_database_row_array[Config_commodity::description], 'title' => $temp_database_row_array[Config_commodity::title], 'price' => $temp_database_row_array[Config_commodity::price], 'url' => 'upload/default.jpg', 'name' => $userinfo[Config_user::log_name], 'time' => get_time($temp_database_row_array[Config_commodity::release_date]), 'star_numbers' => $temp_database_row_array[Config_commodity::praise], 'message_numbers' => $temp_database_row_array[Config_commodity::leave_message_time], 'id' => $temp_database_row_array[Config_commodity::id]); } //5.释放资源 mysqli_free_result($reval); return array('page' => $page, 'array' => $array); }
function get_leave_message($commodity_id, $conn) { require_once 'class/Config_leave_message.php'; require_once 'class/DBpagination.php'; require_once 'class/Info_user.php'; require_once 'class/Config_user.php'; $page = isset($_REQUEST['page']) ? (int) $_GET['id'] : 1; $dbtraerser = new DBpagination(Config_leave_message::tbl_name, ' where ' . Config_leave_message::commodity_id . ' = ' . "'" . $commodity_id . "'", $page, MESSAGE_EACH_PAGE, array(Config_leave_message::content, Config_leave_message::time, Config_leave_message::talker)); $retval = $dbtraerser->excute($conn); $array_message = array(); while (($temp_database_row_array = mysqli_fetch_array($retval, MYSQLI_ASSOC)) != null) { $temp_user = Info_user::get_user_avatar_and_logname($conn, $temp_database_row_array[Config_leave_message::talker]); $array_message[] = array('description' => $temp_database_row_array[Config_leave_message::content], 'time' => get_time($temp_database_row_array[Config_leave_message::time]), 'nickname' => $temp_user[Config_user::log_name], 'img' => 'upload/avatar.png'); } mysqli_free_result($retval); return $array_message; }
function found_transactions($conn) { $page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : 1; $where = ' where ' . Config_transaction::table_name . "." . Config_transaction::choosed_id . ' = ' . Config_commodity::table_name . "." . Config_commodity::id; if (isset($_GET['type'])) { if ($_GET['type'] == 'skill') { $where .= ' AND ' . Config_transaction::table_name . "." . Config_transaction::commodity_holder_id . ' = ' . "'" . $_SESSION['CURRENT_LOGIN_ID'] . "'"; } else { $where .= ' AND ' . Config_transaction::table_name . "." . Config_transaction::commodity_buyer_id . ' = ' . "'" . $_SESSION['CURRENT_LOGIN_ID'] . "'"; } } else { $where .= ' AND (' . Config_transaction::table_name . "." . Config_transaction::commodity_buyer_id . ' = ' . "'" . $_SESSION['CURRENT_LOGIN_ID'] . "'" . ' OR ' . Config_transaction::table_name . "." . Config_transaction::commodity_holder_id . ' = ' . "'" . $_SESSION['CURRENT_LOGIN_ID'] . "'" . ')'; } $table_name = Config_transaction::table_name . "," . Config_commodity::table_name; $choose_fields = array(Config_transaction::table_name . "." . Config_transaction::commodity_buyer_id, Config_transaction::table_name . "." . Config_transaction::commodity_holder_id, Config_commodity::table_name . "." . Config_commodity::title, Config_commodity::table_name . "." . Config_commodity::price, Config_commodity::table_name . "." . Config_commodity::id); $DBpagination = new DBpagination($table_name, $where, $page, TRANSACTION_EACH_PAGE, $choose_fields); $retval = $DBpagination->excute($conn); return $retval; }
require_once 'class/Config_transaction.php'; require_once 'class/Config.php'; require_once 'class/Config_commodity.php'; // require_once 'Include_picture.php'; $conn = Config::connect(); $page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : 1; $user_id = $_SESSION['CURRENT_LOGIN_ID']; $table_name = Config_evaluation::tbl_name . ',' . Config_user::table_name . "," . Config_commodity::table_name; $choose_fields = array(Config_user::table_name . "." . Config_user::pic_path, Config_user::table_name . "." . Config_user::log_name, Config_evaluation::tbl_name . "." . Config_evaluation::evaluate_time, Config_evaluation::tbl_name . "." . Config_evaluation::score1, Config_evaluation::tbl_name . "." . Config_evaluation::score2, Config_evaluation::tbl_name . "." . Config_evaluation::score3, Config_evaluation::tbl_name . "." . Config_evaluation::score, Config_commodity::table_name . "." . Config_commodity::title, Config_commodity::table_name . '.' . Config_commodity::price); if (isset($_REQUEST['evaluation'])) { $where = search_evaluation(); } else { //如果是查找别人评价自己的 $where = search_evaluated(); } $DBpagination = new DBpagination($table_name, $where, $page, EVALUATION_PAGE_SIZE, $choose_fields); $retval = $DBpagination->excute($conn); $array_for_html = array(); while (($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) != NULL) { $array_for_html[] = array('url_header' => 'upload/avatar.png', 'title' => $row[Config_commodity::title], 'price' => $row[Config_commodity::price], 'username' => $row[Config_user::log_name], 'point_study' => $row[Config_evaluation::score1], 'point_care' => $row[Config_evaluation::score2], 'point_total' => $row[Config_evaluation::score], 'time' => $row[Config_evaluation::evaluate_time]); } //display $smarty->assign('reviews', $array_for_html); $smarty->display('My/my-review.html'); mysqli_free_result($retval); mysqli_close($conn); } else { include 'Login.php'; } function search_evaluated() {