我有一个由 mysql 查询创建的列表和几个<li>以唯一 ID 作为变量的列表。
当我想把这个 ID 放进去时getElementById(<?php $id?>)它不起作用。我已经尝试了所有的引语,但没有奏效。
这是代码;
<ul >
<?php
$query= mysqli_query($con,"Select * from database order by date ASC");
while($row = mysqli_fetch_array($query)){?>
<li onclick="showMlstone(this.value)" value="<?php echo $row[id];?>"><?php echo $row[name];?><p id=<?php echo $row[id];?>></p></li>
<script>
function showMlstone(int) {
var xhttp;
if (int == "") {
document.getElementById(<?php echo $row[id];?>).innerHTML = "";
return;
}
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById(<?php echo $row[id]?>).innerHTML = this.responseText;
}
};
xhttp.open("GET", "get.php?q="+int, true);
xhttp.send();
}
</script>
<?php
</ul>
感谢您的帮助
慕森卡
尚方宝剑之说
摇曳的蔷薇