PHP query function (how to get the fields of the corresponding table through the query criteria)
Get Connected
$db = mysql_connect ("localhost", "root", "root") or Die (Mysql_error ());
echo "Connected to MySQL
";
Connecting to a database
mysql_select_db ("test") or Die (Mysql_error ());
echo "Connected to Database";
Query the data and display it in a table
@ $checked = $_post[' checked ');
@ $result = mysql_query ("SELECT * from Books", $db);
echo "
\ n "; echo "
| Isbn |
Author |
Title |
Price | "; echo "
\ n "; Loop through while ($myrow = Mysql_fetch_row ($result)) { printf ("
| %s |
%s |
%s |
%s | ", $myrow [0], $myrow [1], $myrow [2], $myrow [3]); } echo "
\ n ";
?>
<title>Untitled Document</title>
------Solution--------------------
result = mysql_query ("SELECT * from books where checked= ' $checked '");
------Solution--------------------
if (isset ($_post[' checked ')) {
@ $result = mysql_query ("SELECT * from Books", $db);
echo "
\ n "; echo "
| Isbn |
Author |
Title |
Price | "; echo "
\ n "; Looping through