Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

PHP Question: DELETE FROM...

SpaceshipSpaceship
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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
Close
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
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back