0
while($row=mysqli_fetch_assoc($result)){                        
echo "<tr>";
echo ('<td>'.$row['idNo'].'</td>');
echo ('<td>'.$row['FirstName'].'</td>');
echo ('<td>'.$row['LogId'].'</td>');
echo ('<td>'.$row['PassCode'].'</td>');                  
echo '<td><a href="edit.php?id=' . $row['idNo'] . '">Edit</a></td>';                    
echo '<td><a href="delete_contestant.php?id=' . $row['idNo'] . '">Delete</a></td>';                   
echo("</tr>");}

Code of delete_contestant.php pages are given below. But when i am trying to delete an item it

shows Undefined index: idNo in Line 3

Even i was trying to print $_GET['idNo'] but it was not working.

<?php
include('mysql_connect.php');
echo $_GET['idNo'];
if(isset($_GET['idNo']))
{
    $id=$_GET['idNo'];
    $sql="DELETE FROM addContestant WHERE idNo=$id";
    if(mysqli_query($conn,$sql))
    {
        echo "Item deleted";

    }
    else
        echo "There was a problem".mysqli_error($conn);
}
?>
baao
  • 71,625
  • 17
  • 143
  • 203
Motiur Rahaman
  • 121
  • 1
  • 6
  • your link is `delete_contestant.php?id=` so `id` is not the same as `idNo` – Sean Jul 24 '15 at 18:23
  • Use prepared statements you are open to SQL injections with this code. http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php – chris85 Jul 24 '15 at 18:25
  • If one of the answers below answered your question, the way this site works works, you'd "accept" the answer, more here: [*What should I do when someone answers my question?*](http://stackoverflow.com/help/someone-answers). But only if your question really has been answered. If not, consider adding more details to the question. – baao Jul 24 '15 at 19:20
  • Thanks, so far i moved from writing raw php to Laravel framework. – Motiur Rahaman Apr 11 '18 at 06:58

1 Answers1

3

You don't have a GET parameter called idNo, it's id

echo '<td><a href="edit.php?id=' /* <<<< id, not idNo  */. $row['idNo'] . '">Edit</a></td>';                    

change your code to

echo $_GET['id'];
if(isset($_GET['id']))
{
    $id=$_GET['id'];
    //  ......

and it should work.

baao
  • 71,625
  • 17
  • 143
  • 203