如何在php mysql中将div值传递给数据库
比如说
我有
<div id='item'>50</div>
是否有可能将div值50传递给select查询where condition
比如说
<php
$sql = "SELECT * FROM TABLE_NAME WHERE id = 50"
?>
答案 0 :(得分:2)
[笑话]只需在您的用户名前加上 A 和tada!你得到了答案! [/笑话]
Javascript -
var reqText = document.getElementById('source_div').innerHTML;
var xhr = new XMLHttpRequest();
xhr.open('GET', 'test.php?req='+reqText, true);
xhr.onload = function() {
//do stuff
};
xhr.send(null);
test.php -
<?php
$req = $_GET['req'];
//use $req in your sql query.
?>