我尝试通过 mySQL 的下拉选项显示一些数据
当用户选择美国选项并单击提交时,页面将转到下一页并仅显示美国的数据
这是我的 test.html 代码
<body>
<table border="0">
<tr>
<th>test
</th>
</tr>
<tr>
<td>Select Foreign Agent Country</td>
<td></td>
<td>
<select>
<option value="US">United States</option>
<option value="AUD">Australia</option>
</select>
</td>
</tr>
<td>
<button type="submit"><a href="showDB.php">submit</a></button>
</td>
</table>
</body>
这是我的第二页 showDB.php
<?php
//connect to server
$connect = mysql_connect("localhost", "root", "");
//connect to database
mysql_select_db("asdasd");
//query the database
//$query = mysql_query("SELECT * FROM auip_wipo_sample");
if($_POST['value'] == 'US') {
// query to get all US records
$query = mysql_query("SELECT * FROM auip_wipo_sample WHERE app_country='US'");
}
elseif($_POST['value'] == 'AUD') {
// query to get all AUD records
$query = mysql_query("SELECT * FROM auip_wipo_sample WHERE app_country='AUD'");
} else {
// query to get all records
$query = mysql_query("SELECT * FROM auip_wipo_sample");
}
//fetch the result
Print "<table border cellpadding=3>";
while($row = mysql_fetch_array($query))
{
Print "<tr>";
Print "<th>Name:</th> <td>".$row['invention_title'] . "</td> ";
Print "<th>Pet:</th> <td>".$row['invention-title'] . " </td></tr>";
}
Print "</table>";
?>
我尝试了上面的代码,但我得到了 2 个错误,它们是
Undefined index: value in C:\xampp\htdocs\folder\showDB.php on line 10
Undefined index: value in C:\xampp\htdocs\folder\showDB.php on line 14
第 10 行是 if($_POST['value'] == 'US') {
第 14 行是 elseif($_POST['value'] == 'AUD') {
任何人都可以给出解决方案
谢谢