Link for same page

时间:2015-09-01 22:24:46

标签: php html

Longtime reader of stackoverflow but second question.

This is what i am doing

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

This is what we do when we use submit button

<?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";
}



?>

I just want to do something like that * without using input type=submit* ..... But dont know how to do Any advice will be appreciated ... Thanks in advance

1 个答案:

答案 0 :(得分:2)

firstly pass the id in the url like so:

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

then check it with:

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

you basically swapping POST for GET