Hello,
I am new in all this and i was hoping you could help me with a little thing so here it is ive got 2 files one is for showing movies from database and there is "delete" button that is taking an a id and deleteing the raw

display.php

<?php
include('config.php');
        $result = mysql_query("SELECT * FROM users")
                or die(mysql_error());




        echo "<table border='1' cellpadding='10'>";
        echo "<tr> <th>Imie</th> <th>Nazwisko</th> <th>Nazwa Użytkownika</th> <th>Email</th><th>Ostatnia Wizyta</th><th></th> <th></th></tr>";

        while($row = mysql_fetch_array( $result )) {

                echo "<tr>";
                echo '<td>' . $row['firstname'] . '</td>';
                echo '<td>' . $row['lastname'] . '</td>';
                echo '<td>' . $row['username'] . '</td>';
                echo '<td>' . $row['email'] . '</td>';
                echo '<td>' . $row['last_visit'] . '</td>';
                echo '<td><a href=record.php?userid=' . $row['userid'] . '">Edit</a></td>';
                echo '<td><a href="delete.php?userid=' . $row['userid'] . '">Delete</a></td>';
                echo "</tr>";
        }

        // close table>
        echo "</table>";
?>

delete.php

<?php

        include('config.php');

        if (isset($_GET['userid']) && is_numeric($_GET['userid']))
        {
                $query = ("DELETE FROM users WHERE fieldname = '".$_GET["userid"]."' LIMIT 1");

$result = mysql_query($query);
                header("Location: display.php");
        }
        else
        {
                header("Location: error.php");
        }

?>

and here is DB:

-- Struktura tabeli dla  `users`
--

CREATE TABLE IF NOT EXISTS `users` (
  `userid` int(25) NOT NULL AUTO_INCREMENT,
  `firstname` varchar(25) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `lastname` varchar(25) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `email` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `username` varchar(25) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `password` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `role` varchar(15) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'customer',
  `last_visit` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`userid`),
  UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Members'' Area' AUTO_INCREMENT=33 ;

I dont know what is wrong with it and its probobly rly simple but i cant get that rly, thanks for help!

$query = ("DELETE FROM users WHERE fieldname = '".$_GET["userid"]."' LIMIT 1");

Change fieldname to userid, bye! ;D

Hello,
Well i lmao and rly thanks for the help as i said it was simple, thanks for you r time =]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.