Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从mysql搜索PHP中的表格结果_Php_Mysql_Sql - Fatal编程技术网

从mysql搜索PHP中的表格结果

从mysql搜索PHP中的表格结果,php,mysql,sql,Php,Mysql,Sql,如何将查询的搜索结果放入表中,然后选择一个条目来更新表单中的详细信息 所以我有我的表格:姓名、地址、电话、邮政编码、电子邮件等 我有一个搜索查询,搜索的邮政编码 我有一个结果列表,然后我想选择一个选择按钮或类似的东西,然后将其余的信息填入我的表格中 表格是这样的 <td><form action="searchresults.php" method="post" name="form1" id="form1"> <table width="100%" borde

如何将查询的搜索结果放入表中,然后选择一个条目来更新表单中的详细信息

所以我有我的表格:姓名、地址、电话、邮政编码、电子邮件等

我有一个搜索查询,搜索的邮政编码

我有一个结果列表,然后我想选择一个选择按钮或类似的东西,然后将其余的信息填入我的表格中

表格是这样的

<td><form action="searchresults.php" method="post" name="form1" id="form1">
  <table width="100%" border="0" cellspacing="1" cellpadding="3">
    <tr>
      <td colspan="3"><strong>Find a Active Physio</strong></td>
    </tr>
    <tr>
      <td width="100">Physio Reference</td>
      <td width="301"><input name="PhysioReference" type="text" id="PhysioReference" /></td>
    </tr>
    <tr>
      <td>Name of Physio</td>
      <td><input name="Physio" type="text" id="Physio" /></td>
    </tr>
    <tr>
      <td>Contact Number</td>
      <td><input name="Number" type="text" id="Number" /></td>
    </tr>
    <tr>
      <td>Address</td>
      <td><input name="PhysiosAddress" type="text" id="PhysiosAddress" /></td>
    </tr>
    <tr>
      <td>Postcode</td>
      <td><input name="postcode" value="" type="text" id="postcode" />
        <input type="submit" name="submit" value="Search" /></td>
    </tr>
    <tr>
      <td>Physios Email</td>
      <td><input name="PhysiosEmail" type="text" id="PhysiosEmail" /></td>
    </tr>
    <tr>
      <td colspan="3" align="center">&nbsp;</td>
    </tr>
  </table>
</form></td>
像这样的搜索结果需要把它们放到一个表中

<?php

require_once('auth.php');

$host=""; // Host name 
$username=""; // Mysql username
$password=""; // Mysql password 
$db_name=""; // Database name 
$tbl_name="Physio"; // Table name 

 // Connect to server and select database.
   mysql_connect($host, $username, $password)or die("cannot connect"); 
   mysql_select_db($db_name)or die("cannot select DB");

    if(!isset($_POST['postcode'])) {
      header ("location:index.php");
     } 
     echo "<p> Results </p>" ;
 $search_sql = "SELECT * FROM `Physio` WHERE Postcode like '%" . $_POST['postcode'] . "%'";
 $search_query = mysql_query($search_sql);

    while ($search_rs = mysql_fetch_array($search_query))
    {
   echo $search_rs['Reference'] . '<br>';
   echo $search_rs['Physio'] . '<br>';
   echo $search_rs['Postcode'] . '<br>';
   echo $search_rs['Line1'] . '<br>';
   echo $search_rs['Tel'] . '<br>';
}
if (!empty($search_rs))
{
echo "<p> Results Found </p>" ;
}
else
{
echo "<p> No Results Found </p>" ;
}

   ?>
试试这个

  echo"<table><tr>" ;
  echo '<th>Reference</th><th>Physio</th><th>Postcode</th><th>Line1</th><th>Tel</th></tr>';
    while ($search_rs = mysql_fetch_array($search_query))
         {
         echo '<tr>';
         echo "<td>".$search_rs['Reference'] . "</td>";
         echo "<td>".$search_rs['Physio'] . "</td>";
         echo "<td>".$search_rs['Postcode'] . "</td>";
         echo "<td>".$search_rs['Line1'] . "</td>";
         echo "<td>".$search_rs['Tel'] . "</td>";
         echo '</tr>';
         }
  echo '</table>';
用于学习在php中构建html表


:,你又来了:。又是我了,哈哈,它能正常工作和显示。我刚刚阅读了关于Html表格的内容,我将尝试将它添加到我已经创建的css文件中。好的,很高兴它对您有用:!。请确保接受答案。您知道如何获得单个结果来填充表单中的字段吗?就像在这个表的参考号上创建一个链接,将该行的数据移回到表单中一样?如果需要,可以通过ajax实现。
    echo "<td><a href="url">".$search_rs['Reference'] . "</a></td>";