Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.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
Php 从文本字段向表中添加值_Php_Mysql_Arrays_Html Table_Textfield - Fatal编程技术网

Php 从文本字段向表中添加值

Php 从文本字段向表中添加值,php,mysql,arrays,html-table,textfield,Php,Mysql,Arrays,Html Table,Textfield,有一个文本字段和一个表。如果我们在该文本字段中输入一个值,则需要在数据库的表上显示相应的名称: <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <center><table> <tr><td>no</td><td><input type="text" name="no" autofocus></td>&

有一个文本字段和一个表。如果我们在该文本字段中输入一个值,则需要在数据库的表上显示相应的名称:

<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<center><table>
<tr><td>no</td><td><input type="text" name="no"  autofocus></td></tr>
</table></center>
<br>
<br>
<center>
<table cellpadding="0" cellspacing="0" width="60%" border='1' bgcolor="#999999">
  <thead>
    <tr>
      <th> Element_Number</th>

    </tr>
  </thead>

<?php
if(isset($_POST['no']))
{
    $c=mysql_connect("localhost","root","");
    mysql_select_db("test");
    if(!$c)
    {
        echo "db prob".mysql_error();
    }

    $no=$_POST['no'];
    $qry=mysql_query("select name from opt where no='$no'");
    if(!$qry)
    {
        echo "ret".mysql_error();
    }


        if(mysql_num_rows($qry)!=0)
        {
            $row=mysql_fetch_array($qry);
            $name=$row['name'];
        }
        else
        {
            echo "query Invalid";
        }
    echo    "<td>" .$name."</td></tr>" ;

}
?>
我想做什么来获得这样的输出--->


您需要一个while查询来获取所有结果,而不仅仅是第一个结果
no--001

|element no     |

|   aaa         |


no--002

|element no     |

|   bbb         |
no--001


|element no     |

|   aaa         |

no--002


|element no     |

|   aaa         |

|   bbb         |


 no--003

|element no     |

|   aaa         |

|   bbb         |

|   ccc         |