Please help, Im trying to search for mysql records using an html form to display the corresponding record for the entered primary key. Here's my html form:
<td><input type="submit" name="Submit" value="Search"></td>  
And here's the new.php form action:,
mysql_select_db("Hospital", $con);
   $result = mysql_query("SELECT HOSPNUM FROM t2 WHERE FIRSTNAME='{$_POST["fname"]}'");
 while($row = mysql_fetch_array($result))
 {
   <input name="hnum" type="text" id="hospnum" value="<?php echo $row['HOSPNUM']; ?>"  开发者_运维知识库      />
   }
mysql_close($con);
   ?>
How do I get to display the hospnum in the html inputbox when I input the fname and then click the search button.
Note: This script, as-is, is vulnerable to sql-injections. The code that follows is not dealing with this, as it's out of the scope of the original question. Do not use this code as-is in a production environment.
You have a small problem jumping from PHP to HTML:
<?php
   mysql_select_db("Hospital", $con) or die(mysql_error());
   $fname = $_POST["fname"];
   $result = mysql_query("SELECT HOSPNUM FROM t2 WHERE FIRSTNAME='{$fname}'");
?>
<h3>Results:</h3>
<?php while ( $row = mysql_fetch_array($result) ) { ?>
  <input type="text" name="hnum" value="<?php echo $row["HOSPNUM"]; ?>" />
<?php } ?>
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论