解决方案 »

  1.   

    你这个程序写的真不好啊!MVC 思想根本没有啊。。首先msg($dbname,$dbuser,$dbpass,$dbsj,$dblang);这些值一个也没有,都链接不上数据库又怎么能取到值?其次就算链接上数据库,$mysql = mysql_fetch_array($my),这行你改成$mysql = mysql_fetch_assoc($my)试试,一个是关联数组一个索引加关联所以取不到
      

  2.   

    另外$mysql[Id]应该是$mysql['Id']吧。。你好像都少了""
      

  3.   

    $_POST[search]
    $mysql[Id]
    $mysql[artile_title]
    等这些最好加上引号,否则会有警告。查询后的分页是需要跳转到下一页时,把查询条件都带过去才可以。所以search这个参数需要$_POST与 $_GET都可以获取到。$search = trim($_REQUEST['search']);
    <a href="admin.php?main=main_search&search=<?php echo $search ; ?>&page=<?php echo $pg-1; ?>">上一页</a>  <a href="admin.php?main=main_search&search=<?php echo $search; ?>&page=<?php echo $pg+1; ?>">下一页</a>改成这样看看。<?php
    $search = trim($_REQUEST['search']);msg($dbname,$dbuser,$dbpass,$dbsj,$dblang);
    //$titile = %所% and artile like %的% and artile like %a%;
    $titile = preg_replace( "/\s+/","%' and artile_title like '%",$search);if($title!=''){
        $title = "'%".$titile."%'";
    }// 所 的 空 
    //$sql ="select * from wenzhang where artile_title like $title order by id desc";
    $sql ="select * from wenzhang where artile_title like $title order by id desc";
    //select * from wenzhang where artile_title like 所 % and artile like % 的 order by id desc
    //echo $sql;
    $my = mysql_query($sql);
    $number = mysql_num_rows($my); //总行数
    //echo $number;
    $page = 2;// 设定分页每页的行数
    $pagesize = ceil($number/$page); //能显示几页
    $pg = $_GET['page'];
    if(empty($pg)){
       $pg =1;
    }
    $numbers = ($pg-1)*$page;
    $sql ="select * from wenzhang where artile_title like $title order by id desc limit $numbers,$page";
    //echo $sql;
    $my = mysql_query($sql);
    mysql_close();
    ?>
    <table width="100%" border="0" cellspacing="1" bgcolor="#666666";>
      <tr>
        <td colspan="4" bgcolor="#FFFFFF"><div align="center">文章管理
        
      </td>
      </tr>  <tr>
        <td height="21" bgcolor="#FFFFFF">id</td>
        <td bgcolor="#FFFFFF"><div align="center">标题</div></td>
        <td bgcolor="#FFFFFF"><div align="center">作者</div></td>
        <td bgcolor="#FFFFFF"><div align="center">操作</div></td>
      </tr>
    <?php
    while ($mysql = mysql_fetch_array($my)){
    ?>
      <tr>
      
        <td height="22" bgcolor="#FFFFFF"><?php echo $mysql['Id']; ?></td>
        <td bgcolor="#FFFFFF"><?php echo $mysql['artile_title'] ?></td>
        <td bgcolor="#FFFFFF"><?php echo $mysql['artile_auther']?></td>
        <td bgcolor="#FFFFFF">[<a href="../admin.php?main=main_biji&id=<?php echo $mysql['Id']; ?>">操作</a>][<a href="../admin.php?main=main_del&id=<?php echo $mysql['Id']; ?>">删除</a>]</td>
      </tr>
    <?php 
    }
    ?>
    </table><p>一共<?php echo $number;  ?>条记录 <a href="admin.php?main=main_search&search=<?php echo $search ; ?>&page=<?php echo $pg-1; ?>">上一页</a>  <a href="admin.php?main=main_search&search=<?php echo $search; ?>&page=<?php echo $pg+1; ?>">下一页</a></p>