如何使用按钮[关闭]过滤它时,使用从数据库中检索到的值更改html中的表标记的内容
问题描述:
I am trying to change the data fetched by mysql in a table tag when a button is click. It's like filtering the data in the table by active and inactive
我正在尝试在单击按钮时更改mysql在表标记中提取的数据。 这就像通过活动和非活动 p> div>过滤表中的数据
答
How about this:
<form method=POST>
<select class="form-control input-lg" name=filter onchange="this.form.submit()">
<option value="Active">Active</option>
<option value="Inactive">Inactive</option>
</select>
</form>
答
You could send a get request and pass a value to it to filter:
<?php
$age=""
if(isset($_GET["age"])){
$age=htmlspecialchars($_GET["age"]);
}
$query="SELECT ... FROM ... WHERE age='$age'";
//run query + output
?>
Use this link to filter
<a href="?age=18">Just show 18 year old</a>
Or this form:
<form action="thissite.php" method="get">
<select name="age" id="age">
<option value="18">18</option>
...
</select>
<button type="submit">Filter</button>
</form>