Jump to content

[SOLVED] Deleting Information Stored In a Database


Recommended Posts

hi all, I am trying to delete info that I have entered into my database from my webpage. Here is the site and the way ti looks http://www.freegamespot.net/dancefactory/display.php , and here is the code used for that page.

[code]<?
$username="";
$password="";
$database="";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM Winners";
$result=mysql_query($query);
$num=mysql_numrows($result);
?>

<font color="#FFFFFF"><?

if (isset($_POST['id'])){
$id = $_POST['id'];
mysql_query("DELETE FROM Winners WHERE id = '$id'", $con);
}else {
echo "Nothin was deleted";
}
?>


</font>

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Add Winner</title>
</head>

<body bgcolor="#000000">

<p align="left">
<img border="0" src="1392094530_m.jpg" width="170" height="119">

<font color="#FFFFFF">
<form action="insert.php" method="post">
Date: <input type="text" name="loggedDate">  <br>
First Name: <input type="text" name="firstName">  <br>
Last Name: <input type="text" name="lastName"><br>
Birthdate: <input type="text" name="birth"><br>
Phone Number: <input type="text" name="phone"><br>
Street Number: <input type="text" name="streetNumber">
Street Name: <input type="text" name="streetName">
City: <input type="text" name="city"><br>
State: <input type="text" name="state" size="2">
Zip Code: <input type="text" name="zip">
Prize: <input type="text" name="prize"><br>
E-Mail: <input type="text" name="email"><br>
<input type="Submit" value="Add Winner">
</form></font>

</p>
<table border="0" width="986">
        <tr>
                <td width="200"><font color="#FFFFFF">Add Winner<p>
                <font color="#FFFFFF"><a href="display.php">Display Winner</a></font></td>
                <td width="863" rowspan="3" valign="top">
                <table border="0" width="100%">
                        <tr>

                                <td>&nbsp;


<table border="0" cellspacing="2" cellpadding="2">
<tr>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><a href="<? $orderby = 'id' ?>">ID</a></font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Date</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><a href="<? $orderby = 'name' ?>">Name</a></font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Birthday</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Phone</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Street Number</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Street Name</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">City</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">State</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Zip</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Prize</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">E-Mail</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Edit</font></th>
</tr>

<?
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$date=mysql_result($result,$i,"loggedDate");
$first=mysql_result($result,$i,"firstName");
$last=mysql_result($result,$i,"lastName");
$birth=mysql_result($result,$i,"birth");
$phone=mysql_result($result,$i,"phone");
$streetnumber=mysql_result($result,$i,"streetNumber");
$streetname=mysql_result($result,$i,"streetName");
$city=mysql_result($result,$i,"city");
$state=mysql_result($result,$i,"state");
$zip=mysql_result($result,$i,"zip");
$prize=mysql_result($result,$i,"prize");
$email=mysql_result($result,$i,"email"); 

?>

<form method="POST" action="">
<tr>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$id"; ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$date"; ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$first $last"; ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$birth"; ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$phone";  ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$streetnumber"; ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$streetname";  ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$city";  ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$state";  ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$zip";  ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$prize";  ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$email";  ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><input type="submit" value="delete" name="delete"></font></td></tr> </form>
<?
++$i;
}
?>
</table>
</td>
</tr>
</table>
                <p>

</body>
<?
mysql_close();
?>
<a href="http://www.freegamespot.net/dancefactory/update.php?id=37">Click Here</a>
</html>[/code]

The page will click like it did something but nothing gets deleted. It will show the echo response at the top after clicking one of the delete buttons. There has to be a little something I am missing in here. Please help.
You are not declaring $id before the query to delete records where the $id is matched!

In the form script, add this before each of the submit buttons:

<input type="hidden" name="id" value="<?php echo $id; ?>">

That will ensure you have an id value posted from the specific form.

Then in your query statement to delete the record, change to:

DELETE FROM Winners WHERE id = $_POST['id']
Tried what you said Chip and am getting this error

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/freegames/domains/freegamespot.net/public_html/dancefactory/display.php on line 17

This is the updated code
[code]mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM Winners";
$result=mysql_query($query);
$num=mysql_numrows($result);
?>

<font color="#FFFFFF"><?

if (isset($_POST['id'])){
$id = $_POST['id'];
mysql_query("DELETE FROM Winners WHERE id = '$id'", $con);
}else {
echo "Nothin was deleted";
}
?>


</font>

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Add Winner</title>
</head>

<body bgcolor="#000000">

<p align="left">
<img border="0" src="1392094530_m.jpg" width="170" height="119">

<font color="#FFFFFF">
<form action="insert.php" method="post">
Date: <input type="text" name="loggedDate">  <br>
First Name: <input type="text" name="firstName">  <br>
Last Name: <input type="text" name="lastName"><br>
Birthdate: <input type="text" name="birth"><br>
Phone Number: <input type="text" name="phone"><br>
Street Number: <input type="text" name="streetNumber">
Street Name: <input type="text" name="streetName">
City: <input type="text" name="city"><br>
State: <input type="text" name="state" size="2">
Zip Code: <input type="text" name="zip">
Prize: <input type="text" name="prize"><br>
E-Mail: <input type="text" name="email"><br>
<input type="Submit" value="Add Winner">
</form></font>

</p>
<table border="0" width="986">
        <tr>
                <td width="200"><font color="#FFFFFF">Add Winner<p>
                <font color="#FFFFFF"><a href="display.php">Display Winner</a></font></td>
                <td width="863" rowspan="3" valign="top">
                <table border="0" width="100%">
                        <tr>

                                <td>&nbsp;


<table border="0" cellspacing="2" cellpadding="2">
<tr>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><a href="<? $orderby = 'id' ?>">ID</a></font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Date</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><a href="<? $orderby = 'name' ?>">Name</a></font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Birthday</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Phone</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Street Number</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Street Name</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">City</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">State</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Zip</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Prize</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">E-Mail</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Edit</font></th>
</tr>

<?
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$date=mysql_result($result,$i,"loggedDate");
$first=mysql_result($result,$i,"firstName");
$last=mysql_result($result,$i,"lastName");
$birth=mysql_result($result,$i,"birth");
$phone=mysql_result($result,$i,"phone");
$streetnumber=mysql_result($result,$i,"streetNumber");
$streetname=mysql_result($result,$i,"streetName");
$city=mysql_result($result,$i,"city");
$state=mysql_result($result,$i,"state");
$zip=mysql_result($result,$i,"zip");
$prize=mysql_result($result,$i,"prize");
$email=mysql_result($result,$i,"email"); 

?>

<form method="POST" action="">
<tr>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$id"; ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$date"; ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$first $last"; ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$birth"; ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$phone";  ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$streetnumber"; ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$streetname";  ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$city";  ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$state";  ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$zip";  ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$prize";  ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$email";  ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="submit" value="delete" name="delete"></font></td></tr> </form>
<?
++$i;
}
?>
</table>
</td>
</tr>
</table>
                <p>

</body>
<?
mysql_close();
?>

</html>[/code]
[code]<?
$username="";
$password="";
$database="";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM Winners";
$result=mysql_query($query);
$num=mysql_numrows($result);
?>

<font color="#FFFFFF">

<?php

if (isset($_POST['id'])){
mysql_query("DELETE FROM Winners WHERE id = ".$_POST['id'], $con);
}else {
echo "Nothin was deleted";
}

?>


</font>

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Add Winner</title>
</head>

<body bgcolor="#000000">

<p align="left">
<img border="0" src="1392094530_m.jpg" width="170" height="119">

<font color="#FFFFFF">
<form action="insert.php" method="post">
Date: <input type="text" name="loggedDate">  <br>
First Name: <input type="text" name="firstName">  <br>
Last Name: <input type="text" name="lastName"><br>
Birthdate: <input type="text" name="birth"><br>
Phone Number: <input type="text" name="phone"><br>
Street Number: <input type="text" name="streetNumber">
Street Name: <input type="text" name="streetName">
City: <input type="text" name="city"><br>
State: <input type="text" name="state" size="2">
Zip Code: <input type="text" name="zip">
Prize: <input type="text" name="prize"><br>
E-Mail: <input type="text" name="email"><br>
<input type="Submit" value="Add Winner">
</form></font>

</p>
<table border="0" width="986">
        <tr>
                <td width="200"><font color="#FFFFFF">Add Winner<p>
                <font color="#FFFFFF"><a href="display.php">Display Winner</a></font></td>
                <td width="863" rowspan="3" valign="top">
                <table border="0" width="100%">
                        <tr>

                                <td>&nbsp;


<table border="0" cellspacing="2" cellpadding="2">
<tr>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><a href="<? $orderby = 'id' ?>">ID</a></font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Date</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><a href="<? $orderby = 'name' ?>">Name</a></font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Birthday</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Phone</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Street Number</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Street Name</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">City</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">State</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Zip</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Prize</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">E-Mail</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Edit</font></th>
</tr>

<?
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$date=mysql_result($result,$i,"loggedDate");
$first=mysql_result($result,$i,"firstName");
$last=mysql_result($result,$i,"lastName");
$birth=mysql_result($result,$i,"birth");
$phone=mysql_result($result,$i,"phone");
$streetnumber=mysql_result($result,$i,"streetNumber");
$streetname=mysql_result($result,$i,"streetName");
$city=mysql_result($result,$i,"city");
$state=mysql_result($result,$i,"state");
$zip=mysql_result($result,$i,"zip");
$prize=mysql_result($result,$i,"prize");
$email=mysql_result($result,$i,"email"); 

?>

<form method="POST" action="">
<tr>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$id"; ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$date"; ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$first $last"; ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$birth"; ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$phone";  ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$streetnumber"; ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$streetname";  ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$city";  ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$state";  ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$zip";  ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$prize";  ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$email";  ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="submit" value="delete" name="delete"></font></td></tr> </form>
<?
++$i;
}
?>
</table>
</td>
</tr>
</table>
                <p>

</body>
<?
mysql_close();
?>
<a href="http://www.freegamespot.net/dancefactory/update.php?id=37">Click Here</a>
</html>[/code]
by geroge you did it!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

You have done what 15 other people couldnt do :)

Thank you so much!!

Here is the final code for those who are interested.
[code]<?
$username="";
$password="";
$database="";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM Winners";
$result=mysql_query($query);
$num=mysql_numrows($result);
?>

<font color="#FFFFFF">

<?php

if (isset($_POST['id'])){
mysql_query("DELETE FROM Winners WHERE id = ".$_POST['id']);
}else {
echo "Nothin was deleted";
}

?>


</font>

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Add Winner</title>
</head>

<body bgcolor="#000000">

<p align="left">
<img border="0" src="1392094530_m.jpg" width="170" height="119">

<font color="#FFFFFF">
<form action="insert.php" method="post">
Date: <input type="text" name="loggedDate">  <br>
First Name: <input type="text" name="firstName">  <br>
Last Name: <input type="text" name="lastName"><br>
Birthdate: <input type="text" name="birth"><br>
Phone Number: <input type="text" name="phone"><br>
Street Number: <input type="text" name="streetNumber">
Street Name: <input type="text" name="streetName">
City: <input type="text" name="city"><br>
State: <input type="text" name="state" size="2">
Zip Code: <input type="text" name="zip">
Prize: <input type="text" name="prize"><br>
E-Mail: <input type="text" name="email"><br>
<input type="Submit" value="Add Winner">
</form></font>

</p>
<table border="0" width="986">
        <tr>
                <td width="200"><font color="#FFFFFF">Add Winner<p>
                <font color="#FFFFFF"><a href="display.php">Display Winner</a></font></td>
                <td width="863" rowspan="3" valign="top">
                <table border="0" width="100%">
                        <tr>

                                <td>&nbsp;


<table border="0" cellspacing="2" cellpadding="2">
<tr>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><a href="<? $orderby = 'id' ?>">ID</a></font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Date</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><a href="<? $orderby = 'name' ?>">Name</a></font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Birthday</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Phone</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Street Number</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Street Name</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">City</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">State</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Zip</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Prize</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">E-Mail</font></th>
<th><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">Edit</font></th>
</tr>

<?
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$date=mysql_result($result,$i,"loggedDate");
$first=mysql_result($result,$i,"firstName");
$last=mysql_result($result,$i,"lastName");
$birth=mysql_result($result,$i,"birth");
$phone=mysql_result($result,$i,"phone");
$streetnumber=mysql_result($result,$i,"streetNumber");
$streetname=mysql_result($result,$i,"streetName");
$city=mysql_result($result,$i,"city");
$state=mysql_result($result,$i,"state");
$zip=mysql_result($result,$i,"zip");
$prize=mysql_result($result,$i,"prize");
$email=mysql_result($result,$i,"email"); 

?>

<form method="POST" action="">
<tr>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$id"; ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$date"; ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$first $last"; ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$birth"; ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$phone";  ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$streetnumber"; ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$streetname";  ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$city";  ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$state";  ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$zip";  ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$prize";  ?></font></td>
<td bgcolor="#202020"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><? echo "$email";  ?></font></td>
<td bgcolor="#333333"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="submit" value="delete" name="delete"></font></td></tr> </form>
<?
++$i;
}
?>
</table>
</td>
</tr>
</table>
                <p>

</body>
<?
mysql_close();
?>
<a href="http://www.freegamespot.net/dancefactory/update.php?id=37">Click Here</a>
</html>[/code]
For future reference, when using mysql_query($query, $con), you only use $con when you are specifying a particular databse connection to use.  If you do not specify a connection and just use mysql_query($query), it will automatically use the last database connection.  In your case you are specifying a connection stored in a variable $con, but this has not been declared.  Normally this would be declared using something like:

$con = mysql_connect(localhost,$username,$password);

then you could use:

mysql_query("DELETE FROM Winners WHERE id = ".$_POST['id'],$con);
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.