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

WBOY
Release: 2016-06-13 12:01:09
Original
1019 people have browsed it

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

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

------解决方案--------------------
result = mysql_query("select * from books where checked=‘$checked’ ");
------解决方案--------------------
if(isset($_POST['checked'])){
@$result = mysql_query("select * from books",$db);
    echo "

\n";                                      
    echo "
             
             
             
             
             ";                                                     
    echo "\n";                                                 
    //循环遍历                                                          
isbn author title price
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template