如何让查询在任何列表框选择更改上运行
if(isset($_POST['select'])){
$newselection=$_POST['select'];
$query = "SELECT count(*) FROM listings where description=" . $newselection. "";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "Number of rows: {$row['count(*)']}";
}
}
目前仅在按下提交按钮时才有效
我试图避免使用j .. ..
* 我还有其他运行ajax的查询
if(isset($_POST['button1'])){
$selection=$_POST['select'];
$queryres = "SELECT * FROM listings where description=" . $selection. "";
$resultres = mysql_query($queryres);
while($rowres = mysql_fetch_array($resultres, MYSQL_ASSOC))
{
echo "<div style='position: absolute; left: 294px; top: 16px;' title='Site map' class='myclass'> <img src={$rowres['picture1']} alt=''/></div>" ;
echo "<div style='position: absolute; left: 294px; top: 116px;' class='myclass'>Number:{$rowres['number']} <br>Description : {$rowres['description']} <br><br></div>" ;
}
}
答案 0 :(得分:1)
尝试这个(它与php代码无关,它是html)
<option onchange="this.submit();">
答案 1 :(得分:0)
JS是用户单击提交按钮的唯一选择。像<select onchange="submit();">
这样的东西就足够了。