I'm making a website where you can find manuals of different brands of cars. I have a table with ID, NAME, LINK, and CATEGORY. I want that if you click the DIV with the attribute "ford", you select all from the table where category is ford. This is my code:
jQuery
$('div').click(function(){
var cat = $(this).attr('category');
});
and the SQL:
$connect = new PDO('mysql:host=localhost;dbname=manuals', 'root','');
$cmd = $connect -> query("SELECT * FROM `manuals` WHERE `category`='ford'");
$resultado = $cmd->fetchAll(PDO::FETCH_ASSOC);
I know that PHP is a server side language and JS not, and JS is event driven, and all the story, but what is the easiest way to achieve this? Do I need to use forms and stuff?
Sorry for bad english!
使用$ .ajax或$ .post调用,并将变量作为post(或get)变量传递。
U can use AJAX() to get HTTP communication with PHP in backend. see more in [link] http://api.jquery.com/jQuery.ajax/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.