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>
isbn |