Delete specific row in database table and generatet html table

Valentin Gjorgoski

This is my delete page :

<?php 
require('includes/config.php'); 

    $id = $_GET['ID'];
    $pdoConnect = new PDO($db);
    $query='DELETE * FROM studentraspored WHERE ID = "' . $id . '" ';
    $pdoResult = $db->prepare($query);

    $pdoExec = $pdoResult->execute($query);

    header('location:index.php');
?>

This is generated table in my “memberpage.php”:

if (count($rows)){
    foreach ($rows as $row) {       
        $_SESSION['row'] = $rows;
        $id = floatval($row['ID']);
        echo "<tr>" .
            '<form action="delete_raspored.php" method="post">'.
            "<td>" . $row["ID"] . "</td>" .
            "<td>" . $row["den"] . "</td>" .
            "<td>" . $row["chas"] . "</td>" .
            "<td>" . $row["predmet"] . "</td>" .
            "<td>" . $row["profesor"] . "</td>" .               
            "<td>" . $row["prostorija"] . "</td>" .
            "<td>" . $row["tip"] . "</td>" .
            '<td><input type="submit" id="' . $id . '" value="Delete" ></td>'.
            "</form>".
            "</tr>"

This not working properly. I don't understand why maybe something i missed with floatval

chris85

Start by trying this:

<?php 
require('includes/config.php'); 
$id = $_GET['ID'];
$query='DELETE FROM studentraspored WHERE ID = ?';
$pdoResult = $db->prepare($query);
$pdoResult->execute(array($id));
header('location:index.php');
exit();

Note the placeholder in place of the actual value, this will prevent SQL injections. The value is passed in in the execute, or you could bind it (http://php.net/manual/en/pdostatement.bindparam.php). http://php.net/manual/en/pdo.prepared-statements.php

The delete syntax was also off, delete deletes a whole row not specific columns, http://dev.mysql.com/doc/refman/5.7/en/delete.html.

In your form I also don't see an element named ID so that could be another issue and your form is submitting via POST, not GET.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

codeigniter - remove specific table row without delete it in database

From Dev

Delete specific row in CSV file using HTML Table

From Dev

Beginner: Delete row from Table and Database PHP/HTML/MySQL

From Dev

delete a specific row of a table using php

From Dev

delete a row from table based on a specific association

From Dev

Delete multiple table cells from specific row

From Dev

delete a row from table based on a specific association

From Dev

delete a specific row of a table using php

From Dev

Delete row wordpress custom database table

From Dev

Delete row from database with a button in table (PHP)

From Dev

Copy specific row in another row in html table

From Dev

Delete from html table made by database PHP

From Dev

How to delete a row in html table which is populated based on MySQL database values?

From Dev

delete a row in table

From Dev

delete duplicate row on table

From Dev

Wordpress delete row in a table

From Dev

How do I delete a specific table row in CodeIgniter?

From Dev

How to delete a specific row of a dynamic table using JQuery

From Dev

How to delete specific table row from backend and frontend?

From Dev

How to delete a particular row in database table in wordpress using wpdb?

From Dev

Delete specific rows in Oracle Database using SAS table

From Dev

Insert into a specific row of a table

From Dev

How to get an image to the database, and set it as a "tooltipText()" for the table for a specific row

From Dev

Delete individual SQLAlchemy row from an HTML table with flask

From Dev

Unable to delete row from html table using jquery

From Dev

How to delete a selected row in a html table by using jQuery?

From Java

Table add row, edit row, save row, delete row Using HTML, CSS, JS

From Dev

How to view data of a specific row in a database when a specific row is clicked in a table

From Dev

Find specific table row containing substring text of a jquery variable of html

Related Related

  1. 1

    codeigniter - remove specific table row without delete it in database

  2. 2

    Delete specific row in CSV file using HTML Table

  3. 3

    Beginner: Delete row from Table and Database PHP/HTML/MySQL

  4. 4

    delete a specific row of a table using php

  5. 5

    delete a row from table based on a specific association

  6. 6

    Delete multiple table cells from specific row

  7. 7

    delete a row from table based on a specific association

  8. 8

    delete a specific row of a table using php

  9. 9

    Delete row wordpress custom database table

  10. 10

    Delete row from database with a button in table (PHP)

  11. 11

    Copy specific row in another row in html table

  12. 12

    Delete from html table made by database PHP

  13. 13

    How to delete a row in html table which is populated based on MySQL database values?

  14. 14

    delete a row in table

  15. 15

    delete duplicate row on table

  16. 16

    Wordpress delete row in a table

  17. 17

    How do I delete a specific table row in CodeIgniter?

  18. 18

    How to delete a specific row of a dynamic table using JQuery

  19. 19

    How to delete specific table row from backend and frontend?

  20. 20

    How to delete a particular row in database table in wordpress using wpdb?

  21. 21

    Delete specific rows in Oracle Database using SAS table

  22. 22

    Insert into a specific row of a table

  23. 23

    How to get an image to the database, and set it as a "tooltipText()" for the table for a specific row

  24. 24

    Delete individual SQLAlchemy row from an HTML table with flask

  25. 25

    Unable to delete row from html table using jquery

  26. 26

    How to delete a selected row in a html table by using jQuery?

  27. 27

    Table add row, edit row, save row, delete row Using HTML, CSS, JS

  28. 28

    How to view data of a specific row in a database when a specific row is clicked in a table

  29. 29

    Find specific table row containing substring text of a jquery variable of html

HotTag

Archive