config.php页面<?php
$mysql_host = "127.0.0.1:3306";
$mysql_user="root";
$mysql_pwd="123456";
$mysql_db="b2c";
?>
function.php页面<?php
require_once 'config.php';
// 复杂查询操作(带分页,条件,排序,字段可以不齐全)#传$paramSql进来的时候记得先用mysql_real_escape_string过滤一下
function search($tableName, $currentPage, $pageSize, $order, $sort, $columnArray, $paramSql) {
    $con = mysql_connect($GLOBALS["mysql_host"], $GLOBALS["mysql_user"], $GLOBALS["mysql_pwd"]);
    mysql_query("set names 'utf8' ");
    mysql_query("set character_set_client=utf8");
    mysql_query("set character_set_results=utf8");
    if (!$con) {
        return '连接错误';
    } else {
        $orderSql = "";
        if ($order && $sort) {
            $orderSql = "order by $order $sort";
        } 
        $limitSql="";
        if($currentPage && $pageSize){
            $limitSql="limit " . ($currentPage-1) * $pageSize . ",$pageSize";
        }
        mysql_select_db($GLOBALS["mysql_db"], $con);
        $keys = array_keys($columnArray);
        $str = implode(",", $keys);
        $sql = "SELECT $str FROM $tableName $paramSql $orderSql $limitSql";
        $result = mysql_query($sql, $con);
        mysql_close($con);
        $allresult = array();
        while ($row = mysql_fetch_object($result)) {
            $values = array();
            foreach ($keys as $key) {
                array_push($values, $row -> $key);
            } 
            $obj = array_combine($keys, $values);
            array_push($allresult, $obj);
        } 
        return $allresult;
    } 

?>
index.php页面<!doctype html>
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
 </head>
 <body>
 <style type="text/css">
table {
width: 95%;
padding: 0;
margin: 0;
border-collapse:collapse;
border-spacing:0;
}
th {
font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
color: #4f6b72;
border: 1px solid #C1DAD7;
letter-spacing: 2px;
text-transform: uppercase;
text-align: left;
padding: 5px 5px 5px 10px;
background: #CAE8EA url(images/bg_header.jpg) no-repeat;
}
 
td {
border: 1px solid #C1DAD7;
background: #fff;
font-size: 11px;
padding: 5px 5px 5px 10px;
color: #4f6b72;
word-wrap: break-word;
word-break: normal;
white-space: nowrap;
}
</style>
<?php
include 'function.php';
$tableName = "user";
$columnArray = array("id" => "", "name" => "", "age" => "", "sex" => "", "birth" => "");
$id = "5";
$currentPage = 1;
$pageSize = 10;
$order = "birth";
$sort = "desc";
$paramSql = null;
$list = search($tableName, $currentPage, $pageSize, $order, $sort, $columnArray, $paramSql);
 
?>
<table>
<tr><th>ID</th><th>姓名</th><th>年龄</th><th>性别</th><th>生日</th></tr>
<?php
foreach($list as $obj) {
echo "<tr><td>" . $obj['id'] . "</td><td>" . $obj['name'] . "</td><td>" . $obj['age'] . "</td><td>" . $obj['sex'] . "</td><td>" . $obj['birth'] . "</td></tr>";

 
?>
////////////////////////这里怎么带分页
/////////////显示首页、下页、上页、未页 1 2 3 ... 10 11
</table>
 </body>
</html>