通过键入搜索选择数据并在同一个表中显示

时间:2013-09-03 08:27:51

标签: php mysql

我有一张桌子,我有一个搜索框(输入类型=“文字”),其中你输入你在表格中寻找的联系人的姓名和号码。

我想要实现的是这种类型选择的结果将在同一张表中显示/显示!

我想知道的是如何识别已键入的选择,以便我可以在'SELECT * FROM table WHERE'函数中进行处理,这样我就可以添加此变量以使sql在我的搜索中找到它桌子。

通常我使用config.php页面制作sql,然后这将在新页面上显示结果,但这次我希望结果在同一页面的同一个表格中显示!

这可能吗?

我的搜索框型号:

<legend>Voer het Naam en Nummer in dat je wilt opzoeken</legend>

<input type="text"  id="Naam" name="Naam" placeholder="Voer een Naam in" /><br/> 
<input type="text"  id="Nummer" name="Nummer" placeholder="Voer een Nummer in" /><br/>

我的表:

<?php

    include("pagination.php"); 

        if(isset($res))
        {
            //creating table
            echo '<table style="width:1500px; cell-padding:4px; cell-spacing:0; margin:auto;">';       
            echo'<th>id</th><th>Time</th><th>Answered Y/N</th></th><th>Naam</th><th>Caller ID</th>'; 

           while($result = mysql_fetch_assoc($res))
            {
              echo '<tr>';

              echo '<td>'.$result['callapiid'].'</td>'.'<td>'.$result['statusCalling'].'</td>';
              if ($result['statusAnswered'] =="NULL"||$result['statusAnswered'] =="Null" || $result['statusAnswered'] =="null" || $result['statusAnswered'] =="")
      {
      echo "<td>Not Answered!</td>";
      }
    else
      {
      echo "<td>Answered!</td>";
      }
              echo '<td>'.$result['calleridname'].'</td>'.'<td>'.$result['calleridnum'].'</td>' ;
              echo '</tr>';
            }
            echo '</table>';
        }
    ?>

&安培; pagination.php中的$ res变量:

<?php


$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  // select database
  mysql_select_db("voizxl_wachtrij", $con); ////provide database name

 $query = mysql_query("SELECT * FROM Callflow");
 $total_rows = mysql_num_rows($query);

 $base_url = 'https://localhost/pagi/';
  $per_page = 50;                           //number of results to shown per page 
  $num_links = 8;                           // how many links you want to show
  $total_rows = $total_rows; 
  $cur_page = 1;                           // set default current page to 1

if(isset($_GET['page']))
    {
      $cur_page = $_GET['page'];
      $cur_page = ($cur_page < 1)? 1 : $cur_page;            //if page no. in url is less then 1 or -ve
    }

  $offset = ($cur_page-1)*$per_page;                //setting offset

  $pages = ceil($total_rows/$per_page);              // no of page to be created    

 $start = (($cur_page - $num_links) > 0) ? ($cur_page - ($num_links - 1)) : 1;
    $end   = (($cur_page + $num_links) < $pages) ? ($cur_page + $num_links) : $pages;

 $res = mysql_query("SELECT * FROM Callflow LIMIT ".$per_page." OFFSET ".$offset);

 mysql_close($con);
 ?>

我很感激您的帮助和建议,先谢谢您!

示例:http://datatables.net/examples/api/multi_filter.html

0 个答案:

没有答案