totesmagotes
12-17-2010, 07:15 AM
So I have my site almost all setup, except I want to allow users the ability to delete data from their games.
So I have it setup where their data is one one page, listed via looping. Under each, their is a delete button which looks like this:
echo "<a href=\"delete_game.php?id=" . $index . "\">Delete</a>";
So ive got it working fine the $index variable is being pulled down, and transferred to the delete_game page.
On the delete game page I say "Do you really want to delete this game"
Then wrote:
if(isset($_POST['yes'])) {
$query = mysql_query("DELETE FROM games WHERE index='$index'");
if($query) {
echo "The game has been deleted";
} else {
echo "The game could not be deleted";
}
Every single time it says "the game could not be deleted" I have tried it since by trying to the delete the row by a different variable and it works.
So the issue is $index is my auto increment primary key, but it wont let me delete by it, so how do I do this?
Or do I really need to pass each and every unique variable from page to page, and do it that way?
Help is greatly appreciated.
Thanks
So I have it setup where their data is one one page, listed via looping. Under each, their is a delete button which looks like this:
echo "<a href=\"delete_game.php?id=" . $index . "\">Delete</a>";
So ive got it working fine the $index variable is being pulled down, and transferred to the delete_game page.
On the delete game page I say "Do you really want to delete this game"
Then wrote:
if(isset($_POST['yes'])) {
$query = mysql_query("DELETE FROM games WHERE index='$index'");
if($query) {
echo "The game has been deleted";
} else {
echo "The game could not be deleted";
}
Every single time it says "the game could not be deleted" I have tried it since by trying to the delete the row by a different variable and it works.
So the issue is $index is my auto increment primary key, but it wont let me delete by it, so how do I do this?
Or do I really need to pass each and every unique variable from page to page, and do it that way?
Help is greatly appreciated.
Thanks