我的工作有问题。基于数据库的按钮和值重复。当每次重复点击所选按钮时,我希望将当前页面中的选定值放入弹出页面。弹出页面是PHP的外部页面。
这是我的整个代码
<html>
<head>
<!-- popup -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.ui/1.8.6/jquery-ui.min.js"></script>
<link type="text/css" rel="Stylesheet" href="http://ajax.microsoft.com/ajax/jquery.ui/1.8.6/themes/smoothness/jquery-ui.css">
<script>
$("a#selector").live("click", function(){
$(".overlayInner").load("callinboundcall.php",
// the following is the callback
function(){$(".overlayOuter").fadeIn(100); })
});
</script>
<style type="text/css">
.overlayOuter{
background:rgba(255,255,255,0.5);
opacity:0.99;
display:none;
height:100%;
left:0;
position:absolute;
top:0;
width:100%;
z-index:100001;
}
.overlayInner{
position:absolute;
background:rgba(255,255,255,1);
border: 1px solid grey;
opacity: 1.7;
overflow:scroll;
top:7%;/*or whatever*/
left:27%; /*or whatever*/
width:45%;
height:75%;
z-index:100001;
}
</style>
</head>
<body>
<?php>
$call = pg_query("SELECT InputDate,CallId,AgentName,Reviewer,SalamPembuka,KonfirmasiNamaCust,VerifikasiData,KemampuanBertanya,ProductKnowledge,Solusi,AlternativeSolusi ,SistemPelaporan,Empati,Responsif,RamahSopan,PercayaDiri,HoldCall,OfferHelp,Penutup,GrandTotal FROM Call WHERE InputDate >= '$start' AND InputDate <= '$end'");
while($result=pg_fetch_row($call))
{
echo
"
<tr>
<td align=\"center\" class=\"form\">$result[0]</td>
<td align=\"center\" class=\"form\">$result[1]</td>
<td align=\"center\" class=\"form\">$result[2]</td>
<td align=\"center\" class=\"form\">$result[3]</td>
<td align=\"center\" class=\"form\">$result[4]</td>
<td align=\"center\" class=\"form\">$result[5]</td>
<td align=\"center\" class=\"form\">$result[6]</td>
<td align=\"center\" class=\"form\">$result[7]</td>
<td align=\"center\" class=\"form\">$result[8]</td>
<td align=\"center\" class=\"form\">$result[9]</td>
<td align=\"center\" class=\"form\">$result[10]</td>
<td align=\"center\" class=\"form\">$result[11]</td>
<td align=\"center\" class=\"form\">$result[12]</td>
<td align=\"center\" class=\"form\">$result[13]</td>
<td align=\"center\" class=\"form\">$result[14]</td>
<td align=\"center\" class=\"form\">$result[15]</td>
<td align=\"center\" class=\"form\">$result[16]</td>
<td align=\"center\" class=\"form\">$result[17]</td>
<td align=\"center\" class=\"form\">$result[18]</td>
<td align=\"center\" class=\"form\">$result[19]</td>
<td class=\"form\" width=\"2%\"><a id=\"selector\" href=\"#\" ><img width=\"120%\" height=\"130%\" src=\"../img/view.png\"/></a></td>
<td align=\"center\" class=\"form\" width=\"2%\"><img width=\"90%\" height=\"90%\" src=\"../img/edit.png\" onclick=\"myDeleteFunction()\"/></td>
<td align=\"center\" class=\"form\" width=\"2%\"><input onclick=\"deleteRow(this.parentNode.parentNode.rowIndex)\" type=\"image\" src=\"../img/delete.png\" alt=\"Submit\" width=\"110%\" height=\"110%\"></td>
</tr>\n
";
}
<?>
</body>
</html>
按钮位于<a id="selector">
。
值$result[1]
将显示在右上角的弹出窗口。该行是重复的结果
我应该做些什么?谢谢你在高级。如果你不明白,请告诉我。 :d
答案 0 :(得分:2)
使用sesions或wuery字符串将有助于在外部页面上传递数据。 所以例如 您使用查询字符串重定向到外部页面 www.ewxample.in?q=yourdata
接收方的在php的帮助下读取相同的数据
<?php
echo $_GET["q"]; //Output: youdata
?>
答案 1 :(得分:1)
您需要将可能使用查询字符串参数的变量传递给callinboundcall.php
文件。你可能想做类似的事情:
<script>
$("a.selector").live("click", function(){
$(".overlayInner").load(this.href,
// the following is the callback
function(){$(".overlayOuter").fadeIn(100);
});
return false;
});
</script>
几点:
id
属性的HTML网页上拥有多个元素。请改用HTML class
属性。href
而非某些任意网址执行此操作将允许您将行号的ID传递给callinboundcall.php
,您将使用$_GET['id']
或您在AJAX中传递的查询字符串参数读取致电callinboundcall.php
鉴于你说CallID
是一个唯一的ID,这里是你PHP的修改版本:
<html>
<head>
<!-- popup -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.ui/1.8.6/jquery-ui.min.js"></script>
<link type="text/css" rel="Stylesheet" href="http://ajax.microsoft.com/ajax/jquery.ui/1.8.6/themes/smoothness/jquery-ui.css">
<script>
$("a.selector").live("click", function(){
$(".overlayInner").load(this.href,
// the following is the callback
function(){$(".overlayOuter").fadeIn(100);
});
return false;
});
</script>
<style type="text/css">
.overlayOuter{
background:rgba(255,255,255,0.5);
opacity:0.99;
display:none;
height:100%;
left:0;
position:absolute;
top:0;
width:100%;
z-index:100001;
}
.overlayInner{
position:absolute;
background:rgba(255,255,255,1);
border: 1px solid grey;
opacity: 1.7;
overflow:scroll;
top:7%;/*or whatever*/
left:27%; /*or whatever*/
width:45%;
height:75%;
z-index:100001;
}
</style>
</head>
<body>
<?php>
$call = pg_query("SELECT InputDate,CallId,AgentName,Reviewer,SalamPembuka,KonfirmasiNamaCust,VerifikasiData,KemampuanBertanya,ProductKnowledge,Solusi,AlternativeSolusi ,SistemPelaporan,Empati,Responsif,RamahSopan,PercayaDiri,HoldCall,OfferHelp,Penutup,GrandTotal FROM Call WHERE InputDate >= '$start' AND InputDate <= '$end'");
$index = 0;
while($result=pg_fetch_row($call))
{
echo
"
<tr>
<td align=\"center\" class=\"form\">$result[0]</td>
<td align=\"center\" class=\"form\">$result[1]</td>
<td align=\"center\" class=\"form\">$result[2]</td>
<td align=\"center\" class=\"form\">$result[3]</td>
<td align=\"center\" class=\"form\">$result[4]</td>
<td align=\"center\" class=\"form\">$result[5]</td>
<td align=\"center\" class=\"form\">$result[6]</td>
<td align=\"center\" class=\"form\">$result[7]</td>
<td align=\"center\" class=\"form\">$result[8]</td>
<td align=\"center\" class=\"form\">$result[9]</td>
<td align=\"center\" class=\"form\">$result[10]</td>
<td align=\"center\" class=\"form\">$result[11]</td>
<td align=\"center\" class=\"form\">$result[12]</td>
<td align=\"center\" class=\"form\">$result[13]</td>
<td align=\"center\" class=\"form\">$result[14]</td>
<td align=\"center\" class=\"form\">$result[15]</td>
<td align=\"center\" class=\"form\">$result[16]</td>
<td align=\"center\" class=\"form\">$result[17]</td>
<td align=\"center\" class=\"form\">$result[18]</td>
<td align=\"center\" class=\"form\">$result[19]</td>
<td class=\"form\" width=\"2%\"><a class=\"selector\" href=\"callinboundcall.php?id={$result[1]}\" ><img width=\"120%\" height=\"130%\" src=\"../img/view.png\"/></a></td>
<td align=\"center\" class=\"form\" width=\"2%\"><img width=\"90%\" height=\"90%\" src=\"../img/edit.png\" onclick=\"myDeleteFunction()\"/></td>
<td align=\"center\" class=\"form\" width=\"2%\"><input onclick=\"deleteRow(this.parentNode.parentNode.rowIndex)\" type=\"image\" src=\"../img/delete.png\" alt=\"Submit\" width=\"110%\" height=\"110%\"></td>
</tr>\n
";
$index++;
}
<?>
</body>
</html>
这就是我的所作所为:
class
而不是id
href
$index
计数器,以了解每个链接应该获取的行号。 这应该替换为每行的唯一标识符,这将更好callinboundcall.php?index=$index
callinboundcall.php?index=$row['id']
会更好。现在,callinboundcall.php
应执行数据库查询以获取SQL查询的行$_GET['id']
:
$call = pg_query("SELECT AlternativeSolusi FROM Call WHERE CallID = ".intval($_GET['id']);
$result=pg_fetch_row($call);
echo $result[0];
进一步的基本阅读: