我尝试通过使用 $_get['sort'] 函数单击表格的第 th 来对表格进行排序
这是我的代码
<?php
//connect to server
$connect = mysql_connect("localhost", "root", "");
//connect to database
//select the database
mysql_select_db("fak_databases");
//submit button
if($_POST['formSubmit'] == "Submit")
{
$country = $_POST['country'];
}
//query the database
if($country == TRUE) {
// query to get all AL records
$query = mysql_query("SELECT * FROM auip_wipo_sample WHERE applicant1_country='$country'");
if ($_GET['sort'] == 'city')
{
$query .= " ORDER BY wipo_applicant1_city";
}
elseif ($_GET['sort'] == 'address')
{
$query .= " ORDER BY applicant1_addr1";
}
}
//fetch the result
Print "<table border cellpadding=3>";
Print "<tr>";
Print "<th><a href="showDB.php?sort=city">City</a></th>";
Print "<th><a href="showDB.php?sort=address">Address</a></th>";
Print "</tr>";
while($row = mysql_fetch_array($query))
{
Print "<tr>";
Print "<td>".$row['wipo_applicant1_city'] . "</td>";
Print "<td>".$row['applicant1_addr1'] . " </td></tr>";
}
Print "</table>";
?>
但我有一个错误
syntax error, unexpected T_STRING
哪条线是
Print "<th><a href="showDB.php?sort=city">City</a></th>";
任何人都可以解决这个问题?
我需要能够单击头表并按字母顺序排序...
我有一个问题,是 $_get['sort'] 函数只排序升序??还是升序和降序?如果只是升序排序,是否有任何功能可以在我单击表头时进行升序和降序排序?
谢谢