如何以HTML格式从用户那里获取多个输入并在MySql数据库中搜索?

时间:2017-04-18 07:44:54

标签: php html mysql relational-database

我正在尝试创建一个带有多个ID的Web表单,并在MySql数据库中搜索该ID,然后在表中返回该行。

PHP脚本

<form method="post" name="display" action="multi.php" />
Enter the name you like to display the data from MySQL:<br>
<input type="text" name="name" multiple />
<input type="submit"/>
</form>
</html>
<?php
mysql_connect("localhost", "root", "root123") or die("Connection  Failed");
mysql_select_db("myDB")or die("Connection Failed");
$name = array();
 foreach ($_POST as $name)
   {
      $query = "SELECT * FROM check_12 where name = '$name'";
   }

  $result = mysql_query($query);
  while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
  echo '<tr>

            <td>'.$line['ID'].'</td>
            <td>'.$line['Name'].'</td>
            <td>'.$line['Email Id'].'</td>
            <td>'.$line['Address'].'</td>
            <td>'.$line['Phone number'].'</td>
            <td>'.$line['Remark'].'</td>

        </tr>';

0 个答案:

没有答案