2015-09-01 109 views
0

长期阅读器的stackoverflow,但第二个问题。链接相同的页面

这是我在做什么

echo "<td><a href = 'http://localhost/map/index.php' 
value='$id' >Delete</a></td>"; 

这是我们做什么,当我们使用提交按钮

<?php 
echo "<body style='background-color:gray'>"; 
if (isset ($_POST['submit'])){ 
include("connection.php"); 
echo " <table id='t01' border='20px solid black'  width='100%' >"; 
echo "<tr>"; 
echo "<th> DETAILS ABOUT DELETION</th>"; 
echo "<td>DELETED SUCCESSFULLY </td></tr>"; 
$id = $_POST["submit"]; 
$select1="DELETE FROM app where id='$id'"; 
$result = $conn->query($select1); 
if ($conn->query($result)==true){ 
echo "<td>DELETED SUCCESSFULLY </td></tr>"; 
} 
echo "</table>"; 
//echo "DELETED SUCCESSFULLY"; 
} 



?> 

我只想做这样的事情*不使用的输入型=提交* .....但不知道该怎么办 任何意见将不胜感激...提前致谢

+0

你可以用'$ _ SERVER [ 'PHP_SELF']'来引用当前脚本。使用'print_r($ _ SERVER)'来查看所有可用的数据。 – Devon

+1

^标题和问题根本不匹配。该评论正在回答标题,而不是问题。 – developerwjk

+0

我应该在哪里使用它? –

回答

2

首先p AS的ID在URL像这样:

echo "<td><a href = 'http://localhost/map/index.php?id=$id'>Delete</a><td>"; 

然后检查:

if (isset ($_GET['id'])){ 
... 

你基本上交换的POST GET

+0

感谢您的评论...但实际上我想留在index.php .. –

+0

你仍然这样做,你提交到同一页面,它只是将该id添加到网址,然后用它来决定删除什么 –

+1

'http://localhost/map/index.php?id = $ id'使用这个链接它会去index.php?id = *东西* ...有没有解决这个问题的方法? –

相关问题