id_view.html:
<div>
<form method="post" action="../tab/tab.php">
<p>按记录序号(ID)查询:
<input name="id" type="text" >
</p>
<p>
<input name="Submit" type="submit"  value="查询" >
</p>
</form>
</div>

解决方案 »

  1.   

      <?php
    include("../conn_mysql.php");//连接数据库的命令
    //$sql="SELECT * FROM new_cus_information"; //sql查询语句
    //$query=mysql_query("$sql");//送出查询语句
    //$assoc= mysql_fetch_assoc($query);///影响的行数    //注释掉
    //echo "$assoc";                                    //注释掉
    if( isset($_POST["page"]) && $_POST["page"] != "") {
    $page = $_POST['page'];

    if($page == "") {
    $page = 1;
    }
    if(is_numeric($page)) {
    $page_size = 15;  //每页多少条数据
    if( isset($_POST["id"]) && $_POST["id"] != "") {
    $id = $_POST['id']; 
    $query = mysql_query("select count(*) as total from new_cus_information where id = '$id'");
    $count = mysql_fetch_row($query);
      $message_count = $count[0];
    $page_count = ceil($message_count / $page_size);
    $offset = ($page - 1) * $page_size;   
    $result = mysql_query("select * from new_cus_information where id = '$id' limit $offset, $page_size");
    }
    else if( isset($_POST["inputer"]) && $_POST["inputer"] != "") {
    $inputer = $_POST['inputer']; 
    $query = mysql_query("select count(*) as total from new_cus_information where inputer = '$inputer'");
    $count = mysql_fetch_row($query);
      $message_count = $count[0];
    $page_count = ceil($message_count / $page_size);
    $offset = ($page - 1) * $page_size;   
    $result = mysql_query("select * from new_cus_information where inputer = '$inputer' limit $offset, $page_size");
    }
    else if( isset($_POST["dates"]) && $_POST["dates"] != "") {
    $date1 = $_POST["nian1"] . "-" . $_POST["yue1"] . "-" . $_POST["ri1"];
    $date2 = $_POST["nian2"] . "-" . $_POST["yue2"] . "-" . $_POST["ri2"]; 
    $query = mysql_query("select count(*) as total from new_cus_information where date between '$date1' and 'date2'");
    $count = mysql_fetch_row($query);
      $message_count = $count[0];
    $page_count = ceil($message_count / $page_size);
    $offset = ($page - 1) * $page_size;   
    $result = mysql_query("select * from new_cus_information where date between '$date1' and '$date2' limit $offset, $page_size");
    }
    else if( isset($_POST["name"]) && $_POST["name"] != "") {
    $name = $_POST['name']; 
    $query = mysql_query("select count(*) as total from new_cus_information where name = '$name'");
    $count = mysql_fetch_row($query);
      $message_count = $count[0];
    $page_count = ceil($message_count / $page_size);
    $offset = ($page - 1) * $page_size;   
    $result = mysql_query("select * from new_cus_information where name = '$name' limit $offset, $page_size");
    }
    else if( isset($_POST["sex"]) && $_POST["sex"] != "") {
    $id = $_POST['sex']; 
    $query = mysql_query("select count(*) as total from new_cus_information where sex = '$sex'");
    $count = mysql_fetch_row($query);
      $message_count = $count[0];
    $page_count = ceil($message_count / $page_size);
    $offset = ($page - 1) * $page_size;   
    $result = mysql_query("select * from new_cus_information where sex = '$sex' limit $offset, $page_size");
    }
    else if( isset($_POST["phone"]) && $_POST["phone"] != "") {
    $phone = $_POST['phone']; 
    $query = mysql_query("select count(*) as total from new_cus_information where phone = '$phone'");
    $count = mysql_fetch_row($query);
      $message_count = $count[0];
    $page_count = ceil($message_count / $page_size);
    $offset = ($page - 1) * $page_size;   
    $result = mysql_query("select * from new_cus_information where phone = '$phone' limit $offset, $page_size");
    }
    else {
    $query = mysql_query("select count(*) as total from new_cus_information");
    $count = mysql_fetch_row($query);
      $message_count = $count[0];
    $page_count = ceil($message_count / $page_size);
    $offset = ($page - 1) * $page_size;   
    $result = mysql_query("select * from new_cus_information limit $offset, $page_size");
    }
    }
    while($row=mysql_fetch_array($result)) {
    //修改的部分
      /*$abc=@iconv("gb2312", "gbk", $abc=$row['0']);**/
       $id=$row['0'];
    $inputer=$row['1'];
       $date=$row['2'];
       $name=$row['3'];
       $sex=$row['4'];
    $phone=$row['5'];
       $email=$row['6'];
       $address=$row['7'];
       $notes=$row['8'];
      ?>
              <tr>          
                <td height="20" bgcolor="#FFFFFF"><div align="center"><input type="checkbox" name="selectBox" id="selectBox" value="checkbox" /></div></td>
                <td height="20" bgcolor="#FFFFFF"><div align="center" class="STYLE1"><div align="center"><?php echo $id ?></div></div></td>
                <td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1"><?php echo $inputer ?></span></div></td>
                <td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1"><?php echo $date ?></span></div></td>
                <td bgcolor="#FFFFFF"><div align="center"><span class="STYLE1"><?php echo $name ?></span></div></td>
                <td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1"><?php echo $sex ?></span></div></td>
                <td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1"><?php echo $phone ?></span></div></td>
                <td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1"><?php echo $email ?></span></div></td>
                <td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1"><?php echo $address ?></span></div></td>
                <td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1"><?php echo $notes ?></span></div></td>
                <td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE4">
                 <input   type=image  name="edit"  src=images/edt.gif   onclick="SelSubmit2()" value="<?php echo $id ?>">编辑&nbsp; &nbsp;
                 <input   type=image  name="delete"  src=images/del.gif   onclick="SelSubmit3()" value="<?php echo $id ?>">删除
                </span></div></td>          
              </tr>
              <?php } ?>
            </table></td>
            <td width="8" background="images/tab_15.gif">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td height="35" background="images/tab_19.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="12" height="35"><img src="images/tab_18.gif" width="12" height="35" /></td>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td class="STYLE4">&nbsp;&nbsp;共有 <?php echo $message_count ?> 条记录,当前第 <?php echo $page ?>/<?php echo $page_count ?> 页</td>
                <td><table border="0" align="right" cellpadding="0" cellspacing="0">
                    <tr>
                      <td width="40"><input name="page"   type=image   src=images/first.gif   onclick="SelSubmit1()" value="1"></td>
                      <td width="45"><input name="page"   type=image   src=images/back.gif   onclick="SelSubmit1()" value="<?php echo ($page - 1) ?>"></td>
                      <td width="45"><input name="page"   type=image   src=images/next.gif   onclick="SelSubmit1()" value="<?php echo ($page + 1) ?>"></td>
                      <td width="40"><input name="page"   type=image   src=images/last.gif   onclick="SelSubmit1()" value="<?php echo $page_count ?>"></td>
                      <td width="100"><div align="center"><span class="STYLE1">转到第
                        <input name="page" type="text" size="4" style="height:12px; width:20px; border:1px solid #999999;" /> 
                        页 </span></div></td>
                      <td width="40"><input   type=image   src=images/go.gif   onclick="SelSubmit1()"></td>
                    </tr>
                </table></td>
              </tr>
            </table></td>
            <td width="16"><img src="images/tab_20.gif" width="16" height="35" /></td>
          </tr>
        </table></td>
      </tr>
    </table>
    </form>
    </body>
    </html>
    [/code]
    如代码所示,我在查询窗体id_view.html通过输入id执行完查询动作,如何能返回父窗体tab.php显示出查询结果?
      

  2.   

    id_view.html: <div>
    <form method="post" action="../tab/tab.php">
    <p>按记录序号(ID)查询:
    <input name="id" type="text" >
    </p>
    <p>
    <input name="Submit" type="submit"  value="查询" >
    </p>
    </form>
    </div>
    tab.php:<?php 
    include("../conn_mysql.php");//连接数据库的命令 if( isset($_POST["page"]) && $_POST["page"] != "") { 
    $page = $_POST['page']; 

    if($page == "") { 
    $page = 1; 

    if(is_numeric($page)) { 
    $page_size = 15;  //每页多少条数据 
    if( isset($_POST["id"]) && $_POST["id"] != "") { 
    $id = $_POST['id']; 
    $query = mysql_query("select count(*) as total from new_cus_information where id = '$id'"); 
    $count = mysql_fetch_row($query); 
    $message_count = $count[0]; 
    $page_count = ceil($message_count / $page_size); 
    $offset = ($page - 1) * $page_size;  
    $result = mysql_query("select * from new_cus_information where id = '$id' limit $offset, $page_size"); 

    else { 
    $query = mysql_query("select count(*) as total from new_cus_information"); 
    $count = mysql_fetch_row($query); 
    $message_count = $count[0]; 
    $page_count = ceil($message_count / $page_size); 
    $offset = ($page - 1) * $page_size;  
    $result = mysql_query("select * from new_cus_information limit $offset, $page_size"); 


    while($row=mysql_fetch_array($result)) { 
    //修改的部分 
    /*$abc=@iconv("gb2312", "gbk", $abc=$row['0']);**/ 
      $id=$row['0']; 
      $inputer=$row['1']; 
      $date=$row['2']; 
      $name=$row['3']; 
      $sex=$row['4']; 
      $phone=$row['5']; 
      $email=$row['6']; 
      $address=$row['7']; 
      $notes=$row['8']; 
    ?> 刚刚没写好,我重新写一遍。
    如代码所示,我在查询窗体id_view.html通过输入id执行完查询动作,如何能返回父窗体tab.php显示出查询结果?
      

  3.   

    php后台主要用 echo 输出信息, 关键是你的JS问题, 没写好,
      

  4.   

    在tab.php最后那行用 echo '输出你要返回的内容';前台html的js操作建议用jqeury写, 它的ajax集成方法很好用
      

  5.   

    哦,我在id_view.html界面查询时,结果只能显示在id_view.html界面上。。
    是否需要在id_view.html上通过js控制查询结果的显示?
      

  6.   

    肯定要, 开始用js提交数据时不跳转页面, 查询后php返回的值时, 再用js处理并显示这个结果