code does not display any errors but still does not execute DELETE

0

The code does not display any errors but still does not execute DELETE.

I created a tag to delete line by line and I used GET for it and it still is not working.

tag <td><a href="delete_rows.php?del=$row[ISBN]">delete</a></td>

GET method:

<?php
include_once('config.php');
if( isset($_GET['del']) )
{
    $ISBN = $_GET['del'];
    $sql= "DELETE FROM books WHERE ISBN='$ISBN'";
    $res= mysqli_query($conn,$sql) or die("Failed".mysqli_error($conn));
    echo "<meta http-equiv='refresh' content='0;url=update.php'>";
}    
?>

Edit to add the full code where the tag is

<html>
<head>
<title></title>
    <link rel="stylesheet" type="text/css" href="stylesheet.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script><script>functionupdateBook(id){varisbn=document.getElementById("ISBN"+id).innerHTML;
            document.getElementById("ISBN").value = isbn;

             var title = document.getElementById("Title"+id).innerHTML;
            document.getElementById("Title").value = title;

             var authorsname = document.getElementById("Authorsname"+id).innerHTML;
            document.getElementById("Authorsname").value = authorsname;

             var edition = document.getElementById("edition"+id).innerHTML;
            document.getElementById("edition").value = edition;

             var year = document.getElementById("year"+id).innerHTML;
            document.getElementById("year").value = year;

             var category = document.getElementById("category"+id).innerHTML;
            document.getElementById("category").value = category;

             var publisher = document.getElementById("publisher"+id).innerHTML;
            document.getElementById("publisher").value = publisher;

             var quantityinstock = document.getElementById("quantityinstock"+id).innerHTML;
            document.getElementById("quantityinstock").value = quantityinstock;

             var price = document.getElementById("price"+id).innerHTML;
            document.getElementById("price").value = price;
        }

        $(document).ready(function(){
            $(".update").click(function(){
                $("#UPDT").toggle();
                $(this).text(function(i,text){
                    return text === "See less" ? "Update" : "See less";
                });
            });
        });
    </script>



</head>
    <body>
<?php
    include('config.php');
    $query = "SELECT * FROM books ORDER BY Title ASC";
    $r=mysqli_query($conn, $query);
?>
    <table cellpadding="2" cellspacing="2" border="0">
        <tr>
    <th>ISBN</th>
    <th> Title </th>
    <th> Author's name</th>
    <th> edition</th>
    <th> year</th>
    <th> category</th>
    <th> publisher</th>
    <th> quantity-in-stock</th>
    <th> price</th>
    </tr>
<?php $id = 0;?>
<?php while($books =mysqli_fetch_object($r)){?>
    <?php $id = $id +1;?>
    <tr>
    <td id="ISBN<?php echo $id ?>"> <?php echo $books->ISBN; ?></td>
    <td id="Title<?php echo $id?>"> <?php echo $books->Title;  ?></td>
    <td id="Authorsname<?php echo $id?>"> <?php echo $books->Authorsname; ?></td>
    <td id="edition<?php echo $id?>"> <?php echo $books->edition;?></td>
    <td id="year<?php echo $id?>"><?php echo $books->year;   ?></td>
    <td id="category<?php echo $id?>"> <?php echo $books->category;   ?></td>
    <td  id="publisher<?php echo $id?>"><?php echo $books->publisher;  ?></td>
    <td id="quantityinstock<?php echo $id?>"> <?php echo $books->quantityinstock; ?></td>
    <td id="price<?php echo $id?>"> <?php echo $books->price; ?></td>
    echo '<img src="data:image/jpeg;base64,'.base64_decode( $books->Image ).'">';
    <td> <button class="update" onclick="updateBook(<?php echo $id?>)">Update</button></td> 
        <td><a href="delete_rows.php?del=$row[ISBN]">delete</a></td>
  </tr>
    <?php } ?>
        </table>

        <form id="UPDT" name="updateform" action="update_books.php" method="POST">

            ISBN:<input type="text" name="ISBN" id ="ISBN" value="<?php echo $books->$ISBN;?>">
            Title:<input type="text" name="Title"  id="Title" value="<?php echo $books->$Title;?>">
            Author's name<input type="text" name="Authorsname" id="Authorsname" value="<?php echo $books->$Authorsname;?>">
            Edition<input type="text" name="edition" id="edition" value="<?php echo $books->$edition;?>">
            Year:<input type="text" name="year" id="year" value="<?php echo $books->$year;?>"> 
            Category: <input type="text" name="category" id ="category" value="<?php echo $books->$category;?>">
            Publisher:<input type="text" name="publisher" id="publisher"  value="<?php echo $books->$publisher;?>">
            Quantity-in-stock:<input type="text" name="quantityinstock" id ="quantityinstock" value="<?php echo $books->$quantityinstock;?>">
            Price:<input type="text" name="price" id="price" value="<?php echo $books->$price;?>">
            <input type="submit" value="Send" name="send">
        </form>

    </body>
</html>

Have someone help please!

    
asked by anonymous 20.04.2017 / 02:25

0 answers