$ // 首先,我发送执行 sql 查询的 php 代码,此代码执行查询以从数据库中获取数据并将所有数据存储在 get_row1 中并将其作为对 ajax 的响应发送
<?php
$connect = mysql_connect("localhost", "root", "");
$data = mysql_select_db("testme", $connect);
$identity = $_REQUEST['id'];
$query = "SELECT * FROM student_demo WHERE id=1";
$getdata = mysql_query($query);
$get_row1 = mysql_fetch_array($getdata);
$data1 = array(
$get_row1[0],
$get_row1[1],
$get_row1[2],
$get_row1[3]
);
print_r($data1);
?>
$ //这会将 $data1 发送回 ajax 代码 $
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
alert(xmlhttp.responseText);
temp1 = xmlhttp.responseText.split("=>");
alert(temp1);
for (var i = 0; i < 10; i++) {
$('.data' + i).val(tmp1[i]);
if (tmp[i] == "[0]") {
document.getelementById("c_name").value = temp1[i];
}
}
}
}
xmlhttp.open("GET", "process.php?id=" + ID, true);
xmlhttp.send();
现在我应该进行哪些更改才能从数组 temp1 中获取值以显示在文本框中$