如何使用div动作激活动态表

时间:2017-03-04 14:32:08

标签: php jquery html css mysql

我与数据库建立了连接,并使用Dreamweaver创建了一个动态表;一切都很好。现在我正在尝试使用Java进行实时搜索,使用表中的搜索框和java reuiers来显示div中的数据。结果显示在另一个表上,虽然我没有在div中写任何内容,但我的表没有改变。现在我需要对表本身进行操作,或者使该表成为div函数。

有人可以帮助我将结果放在同一张桌子上或者给我一个如何操作的例子吗? 我的代码如下:

<?php require_once('Connections/localhost.php'); ?>
<?php

 mysql_select_db($database_localhost, $localhost);


  if (isset($_POST['Searchbox'])) {
    $search = $_POST['Searchbox'];
     $searchresult = mysql_query("SELECT * FROM members WHERE company LIKE          '%".$search."%' or country LIKE '%".$search."%'or adresse LIKE '%".$search."%'or   prcontact LIKE '%".$search."%'or tel LIKE '%".$search."%'or email LIKE '%".$search."%'or website LIKE '%".$search."%'");
  if (mysql_num_rows($searchresult) > 0){
  while ($searcharray = mysql_fetch_array($searchresult)) {
    $query_members = "SELECT * FROM members WHERE company LIKE '%".$search."%' or country LIKE '%".$search."%'or adresse LIKE '%".$search."%'or prcontact LIKE '%".$search."%'or tel LIKE '%".$search."%'or email LIKE '%".$search."%'or website LIKE '%".$search."%'";
     }
    }
      else {
    $query_members = "SELECT details, company, country, adresse, prcontact,  tel, email, website FROM members";
        }
      }

   $query_limit_members = sprintf("%s LIMIT %d, %d",
       $query_members, $startRow_members, $maxRows_members);
        $members = mysql_query($query_limit_members, $localhost) or die(mysql_error());
    $row_members = mysql_fetch_assoc($members);

   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
     <script type="text/javascript" > 
     function getSearch(value) {
        $.post("?", {Searchbox:value},function(data) {
            $("#results").html(data) 
        });
   }
       </script>
      <body>


      <table border="1" align="center">
       <tr>
         <td colspan="8"><form action="" method="POST" name="search"><input name="search_box1" type="text" id="search_box1" placeholder="Search" size="100" onkeyup="getSearch(this.value)" formaction="" /></form></td>
        </tr>

      <tr align="center" valign="middle">
        <td><strong>Details</strong></td>
         <td><strong>Company</strong></td>
         <td><strong>Country</strong></td>
         <td><strong>Adress</strong></td>
        <td><strong>PreContact</strong></td>
        <td><strong>Telefon</strong></td>
        <td><strong>E-Mail</strong></td>
          <td><strong>Website</strong></td>
       </tr>
        <tr>
          <td>&nbsp;</td>
<td><form action="" method="POST" name="search"><input type="text" name="search_box2" id="search_box2" formaction="" /></form></td>
<td><form action="" method="POST" name="search"><input type="text" name="search_box3" id="search_box3" formaction="" /></form></td>
<td><form action="" method="POST" name="search"><input type="text" name="search_box4" id="search_box4" formaction="" /></form></td>
<td><form action="" method="POST" name="search"><input type="text" name="search_box5" id="search_box5" formaction="" /></form></td>
<td><form action="" method="POST" name="search"><input type="text" name="search_box6" id="search_box6" formaction="" /></form></td>
<td><form action="" method="POST" name="search"><input type="text" name="search_box7" id="search_box7" formaction="" /></form></td>
<td><form action="" method="POST" name="search"><input type="text" name="search_box8" id="search_box8" formaction="" /></form></td>
</tr>
     <?php do { ?>
     <tr align="center" valign="middle">
      <td><img src="<?php echo $row_members['details']; ?>" width="120" height="32" /></td>
  <td><?php echo $row_members['company']; ?></td>
  <td><?php echo $row_members['country']; ?></td>

    </tr>
   <?php } while ($row_members = mysql_fetch_assoc($members)); ?>
  </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
   <div id="results"></div>
      </body>

0 个答案:

没有答案