我在数据库中有 3 个数据(客户表)显示
我的 CSS - #form
#form{
position:fixed;
width:320px;min-height:280px;
top:21%;
left:36%;
background-color:#FFF;
padding:10px 10px 20px 10px;
border:1px solid #AAA;
display:none;
z-index:101;
-moz-border-radius: 10px;
-moz-box-shadow: 0 0 10px #aaa;
-webkit-border-radius: 10px;
-webkit-box-shadow: 0 0 10px #aaa;
}
我从网上得到了这段代码(仅限 ajax)
function loadXMLDoc()
{
var xmlhttp;
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)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","test1.php",true);
xmlhttp.send();
这个是我的表格展示
echo "<table width='"900'" cellpadding='"0'" cellspacing='"0'" border='"0'">
<tr>
<td>ID</td>
<td>First name</td>
<td>Last name</td>
</tr>";
$query = mysql("SELECT * FROM `reservation` WHERE `CustID` = '$custid'");
while($row = mysql_fetch_assoc($query){
$reserveid = $row['ReserveID'];
$fname = $row['Fname'];
$lname = $row['lname'];
$age = $row['age'];
echo "<tr>
<td>$fname</td>
<td>$lname</td>
<td>$age</td>
<td></td>
<td><input type='"image'" src='"form.png'" onclick='"'" /></td>
</tr>";
}
我的客户表包含 3 个数据
| ID | First name | Last name |
| 1 | Anjon | Lee |
| 2 | Leo | Bisnar |
| 3 | Joerge | Enero |
你能在这里帮我吗?
我通过使用 while 循环在表中获得了 3 个数据,customer
具有唯一 ID。如果我在input
单击 loadXMLDoc() occur/tirigger
并在 test2 中发送uniqueID
.php并且当数据库中uniqueID=ID
(AJAX 结果成功)时,#form 应该会弹出并显示记录
如果我单击第一个输入,它应该得到
| ID | First name | Last name |
| 1 | Anjon | Lee |
但问题是我不知道如何发送显示数据的唯一
或者我应该说我很困惑如何做到这一点 - PHP 通过 AJAX 发送它是令人困惑的。请帮助我,这是为了我们的项目
<input type='"image'" src='"form.png'" reserveid=$resrveid onclick='"loadXMLDoc(this)'" />
function loadXMLDoc(obj)
{
var rid = obj.getAttribute('reserveid');
var xmlhttp;
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)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","test2.php?id="+rid,true);
xmlhttp.send();
}
希望对您有所帮助!