2017-09-15 91 views
0

我有一个变量这样通过在URL多个变量在PHP

$groupid=$_GET['groupid']; 

,并在同一页上我有这样一个按钮..

<td> 
     <a href="assigncoursedelete.php?id=<?php echo $row->id;?>" onclick="return confirm('Are you sure you wish to delete this Record?');"> 
     <div style="background-color:#CD5C5C; width:30px; padding-left:9px; padding-top:3px; height:28px; color:white"> 
     <em class="fa fa-trash"></em></div> 
    </td> 

,我想传递$groupid在上面的URL变量..

我试过,但它不是传递变量,以删除页..

谁能帮助我如何做到这一点..提前

谢谢..

+0

我建议使用HTTP POST方法通过HTML删除。浏览器/机器人可以预取/关注链接并导致灾难。 – Progrock

回答

1
<td><a href="assigncoursedelete.php?id=<?php echo $row->id;?>&groupid=<?php echo $groupid; ?>" onclick="return confirm('Are you sure you wish to delete this Record?');"><div style="background-color:#CD5C5C; width:30px; padding-left:9px; padding-top:3px; height:28px; color:white"> 
             <em class="fa fa-trash"></em></div></td> 

这会不会对你的工作尝试

+0

这是工作。请尝试。 –

+0

是它的工作..谢谢你.. – user200

1
assigncoursedelete.php?id=<?php echo $row->id;?>&groupid=<?php echo $groupid; ?> 

您必须使用“&”传递多个网址中的数据

+0

谢谢你..它的工作.. – user200

+0

然后请接受它作为有效的答案。乐意效劳。 – pr1nc3

0

您可以试试这个: -

<td> 
    <a href="assigncoursedelete.php?id=<?php echo $row->id."&groupid=".$groupid;?>" onclick="return confirm('Are you sure you wish to delete this Record?');"> 
    <div style="background-color:#CD5C5C; width:30px; padding-left:9px; padding-top:3px; height:28px; color:white"> 
    <em class="fa fa-trash"></em></div> 
</td> 

Happy编码:-)

0

使用php http_build_query函数。这将需要的可能的编码问题护理:

<?php 
$data = [ 
    'id' => 47, 
    'name' => 'this & that' 
]; 

$url = 'destination.php?=' . http_build_query($data, '', '&amp;'); 
?> 
<a href="<?= $url ?>">Do something</a> 

输出:

<a href="destination.php?=id=47&amp;name=this+%26+that">Do something</a>