2011-07-17 43 views
2

?我怎樣才能查詢,以便對任何列表框中選擇更改AJAX - 在列表框中選擇更改PHP事件

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(*)']}"; 
} 
} 

目前當提交按鈕被按下

我試圖避免它只能運行JS ..

*我也有其他查詢運行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>" ; 
} 
} 

回答

1

試試這個(它無關,與PHP代碼,它的HTML)

<option onchange="this.submit();"> 
+0

檢查我的編輯問題 - 我添加了一些信息 – Jabee

0

JS是用戶點擊提交按鈕的唯一選擇。像<select onchange="submit();">可能就足夠了。