php的查询功能(怎么通过查询条件获取相应表的字段)

php的查询功能(如何通过查询条件获取相应表的字段)
<?php
//获得连接
$db = mysql_connect("localhost", "root", "root") or die(mysql_error());
//echo "Connected to MySQL<br/>";
//连接数据库
mysql_select_db("test") or die(mysql_error());
//echo "Connected to Database";

    //查询数据,并用表格显示出来  
@$checked = $_POST['checked'];
@$result = mysql_query("select * from books",$db);
    echo "<table border=1>\n";                                      
    echo "<tr>
         <td>isbn</td>
 <td>author</td>
 <td>title</td>
 <td>price</td>
 ";                                                     
    echo "</tr>\n";                                                 
    //循环遍历                                                          
      while ($myrow = mysql_fetch_row($result)){ 
          printf("<tr>
               <td>%s</td>
   <td>%s</td>
   <td>%s</td>
   <td>%s</td>", $myrow[0], $myrow[1],$myrow[2],$myrow[3]);
            }                                                               
         echo "</table>\n";
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<form action="" name=""><br/>
  <br/>
   <input type="button" value="查询" name="submit"/>
   <input type="text" name="checked"/>
</form>
</body>
</html>

------解决方案--------------------
result = mysql_query("select * from books where checked=‘$checked’ ");
------解决方案--------------------
if(isset($_POST['checked'])){
@$result = mysql_query("select * from books",$db);
    echo "<table border=1>\n";                                      
    echo "<tr>
             <td>isbn</td>
             <td>author</td>
             <td>title</td>
             <td>price</td>
             ";                                                     
    echo "</tr>\n";                                                 
    //循环遍历