2013-03-04 72 views
0

我需要你的幫助來編輯我的腳本,使其輸出結果WHERE title = function(搜索) 如果我輸入:test,它會打印出結果,並將結果作爲標題進行測試。jQuery/MySQL WHERE something = function

search.js:

$('form').submit(function() { 
    var form_data = ($(this).serialize()); 
    window.location.hash = form_data.replace('=','/'); 
    return false; 
}); 

(function() { 

window.App = { 
    Models: {}, 
    Collections: {}, 
    Views: {}, 
    Router: {} 
}; 

App.Router = Backbone.Router.extend({ 
    routes: { 
     '': 'index', 
     'search/:search': 'search', 
     '*other': 'default' 
    }, 

    index: function() { 
     $(document.body).append(""); 
    }, 

    search: function(search) { 
     $('#result').load('search.php'); 
    } 
}); 

new App.Router(); 
Backbone.history.start(); 

})(); 

的search.php

$query = "SELECT title FROM media WHERE title="; 
$result = mysql_query($query); 
$row = mysql_fetch_assoc($result); 
echo $row['title']; 

回答

0

閱讀​​here的文檔。注意你可以將數據傳遞給函數發送到服務器。

瞭解如何通過讀取$_GET$_POST請求變量來訪問服務器上的這些數據。

請勿使用MySql函數。他們已被棄用。您應該使用Mysqli

出於安全原因,請閱讀Mysqli prepared statements

相關問題