以下是一些(简化的)代码示例:
Database.php:
<form>
<select>
<option>1</option>
<option>2
<option>
</select>
<input type="submit" name="apply_filter" />
</form>
<?php
if ( isset( $_POST[ "apply_filter" ] ) ) { // display filtered entries
$filter = $_POST[ "filter" ];
$q = "Select * from table where col = '" . $filter . "'";
$r = mysql_query( $q );
} else { // display all entries
$q = "Select * from table";
$r = mysql_query( $q );
}
while ( $rec = mysql_fetch_assoc( $r ) ) {
echo "<a href='view.php?id=" . $rec[ "id" ] . "'>" . $rec[ "name" ] . "</a><br />"; // this is where the link to the view.php page is...
}
?>
现在如上所述,如果我点击链接,它会带我到“view.php?id=任何内容”。在那个页面上,我只需从url获取ID来显示单个条目:
view.php:
<?php
$id = $_GET[ "id" ];
$q = "Select * from table where id = '" . $id . "'";
$r = mysql_query( $q );
while ( ) {
// display entry
}
?>
如果我现在点击后退按钮,database.php上的表单(用于过滤数据库结果的表单)需要确认才能重新提交。这不仅非常烦人,对我也毫无用处。我该如何解决这个问题?希望我的代码示例和问题说明足够清楚。如果不行,请告诉我,我会尽力说明。