Unstoppable Domains

PHP Question: DELETE FROM...

Spaceship Spaceship
Watch

flishess

Established Member
Impact
6
this is my deletegame.php code that shows the games I can select to delete by the title only:

Code:
<?
include("./config.php");
?>
<html>
<form method="post" action="removegame.php">

<h3>Delete Game:</h3>
<select name="id">
<?php echo $title; ?>
</select>
<br>
<br>
<INPUT TYPE="submit" name="submit" value="submit">
</form>

this is the removegame.php code that needs to remove the game and all data that goes with that particular game:

Code:
<? 

if($_POST['submit'])
{
   include("./config.php");

   $id = mysql_real_escape_string($_POST['id']);

   $result=MYSQL_QUERY("DELETE FROM gamepage WHERE id='$id'"); 

   echo "Query Finished"; 
Header ("Location: ./deletegame.php");
}
?>

The game info is not deleted when I run this script, can someone help me fix my problem?

Thanks in advance!

this is what is in my config for $title:

Code:
//this pulls gamepage title into deletegame.php
$result = mysql_query("SELECT * FROM gamepage"); 
$title = ''; 
while ($row = mysql_fetch_assoc($result)) { 

$title .= '<option value="' . $row['title']. '">' . $row['title']. '</option>'; 

}
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Code:
//this pulls gamepage title into deletegame.php
$result = mysql_query("SELECT * FROM gamepage"); 
$title = ''; 
while ($row = mysql_fetch_assoc($result)) { 

$title .= '<option value="' . $row['id']. '">' . $row['title']. '</option>'; 

}

Also, to optimize your code with the DB:

$result = mysql_query("SELECT `id`,`title` FROM gamepage");
 
0
•••
Let me know if Gydian's solution didn't resolve your issue. Incidentally, you should always issue the exit construct after the header location - you may wish to take a look at this article.
 
0
•••

We're social

Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back