Delete from Checklist

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Delete from Checklist

Post by Dale »

Heres what i have at the moment:

Code: Select all

// Delete Announcement
if($_GET['dfga'] == "announcedelete") {

echo("<form action="admin.php?dfga=announcedeleted" method="post">
<tr valign="top" bgcolor=#104C68>
<td width="100%" colspan="3"><font face="verdana" size="1"><hr></font></td>
</tr>
<tr bgcolor=#104C68>
<td width="100%" colspan="2" bgcolor="#104C68"><font face="verdana" size="2"><b>Delete A Announcement:</b></font></td>
</tr>
<tr bgcolor=#104C68>
<td width="100%"><font face="verdana" size="2">");

$query = "SELECT * FROM dfga_ann"; 
$result = mysql_query($query) or die(mysql_error()); 

while($r=mysql_fetch_array($result)) 
{ 	
	$id=$r["id"];
	$msg=$r["msg"];
	echo "<input type=radio value=$id name=ann> $msg<hr>";
}

echo("</font></td>
</tr>
<tr bgcolor=#104C68>
<td width="100%" colspan="2"><center><input type="submit" value="Delete Announcement"></center></td>
</tr>

</table>
</form>
</center>

</body>
</html>");

}

if($_GET['dfga'] == "announcedeleted") {

// #######################################################################################
// # Delete's Announcement In 'ann' Table
// #######################################################################################

	$id=$r["id"];

$query = "DELETE FROM dfga_ann WHERE id = '$id'";
// DELETE * FROM dfga_ann WHERE id='$id' 
$result = mysql_query($query) or die(mysql_error()); 

if($result) 
    echo "<meta http-equiv="Refresh" content="2; URL=admin.php?dfga=announcedelete">
<tr valign="top" bgcolor=#104C68>
<td width="100%" colspan="3"><font face="verdana" size="1"><hr></font></td>
</tr>
<tr bgcolor=#104C68>
<td width="100%" colspan="2" bgcolor="#104C68"><font face="verdana" size="2"><b>Announcement Deleted!</b> - Please wait...</font></td>
</tr>";

}

Problem is.. well when i select a checkbox (list box) it doesnt delete the announcement. Please tell me where im going wrong and sorry about it being a mess.. thats how i like it :D
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

im assuming you are wanting a system like an e-mail inbox where you click the checkbox and it deletes?

if so use something along these lines

Code: Select all

if (isset($_POST['checkbox']))
{
// do a mysql_query
$query = "DELETE something FROM somewhere WHERE something = '$_POST[checkbox]'";
$runquery = mysql_query($query) or die(mysql_error());
}
else
{
// do nothing
}
just to give you an idea..........
or it could be implemented into your code.......
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

U have lost me.. sorry lol im still new and im not one of these people who say they are new but know the answer to the distance from here the the moon times by the right angle on a triangle which has all this piefagorus's therom or what ever it was.

Im really just after/finding out why this aint deleting the $id that was selected.

Code: Select all

$id=$r["id"]; 
$query = "DELETE FROM dfga_ann WHERE id = '$id'";
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

Code: Select all

$id = $_POST['ann'];
$query = "DELETE FROM dfga_ann WHERE id = '$id'";
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Thanks a lot Wayne :D

My dads name is Wayne.. you aint my dad are you? :p (Then again my Dad isnt into PHP and MySQL, he is into Visual Basic)
Post Reply