Location: PHPKode > scripts > Php AddressBook 2 > php-addressbook-2/delete.php
<?php
if ( isset($id) ) {	
	// Make sure that we want to delete the hub data.
		if ( !isset($delete) ) {
		$sql = "SELECT * FROM addressbook WHERE id = ('$id')";
		$rs = mysql_query($sql) or die ("Query failed");
		$row = mysql_fetch_array($rs);
		echo "Are you sure you want to delete <b>".$row["firstname"]." ".$row["lastname"]."</b><br /><br />
		<input type=button value='No' id='fno' onClick=\"parent.location='javascript:self.history.back()'\" tabindex='1'>
		<input name='Yes' type='submit' id='fyes' onClick=\"parent.location='?title=delete&delete=yes&id=".$row["id"]."'\" class='button'  tabindex='2' value='Yes' />
		";
		// Close DB connection
	}

	// If delete is set to "yes" then delete the data
		if ( isset($delete) ) {
		$query = "DELETE FROM addressbook WHERE id = ('$id')";
		$result = mysql_query($query);
		echo "The data has been deleted.<br><br>
		<input type=button value=\"Back\" id='fback' onClick=\"parent.location='index2.php?title=view'\" tabindex=\"1\">
		";
		// Close DB connection
	}
	
}

if ( isset($gid) ) {	
	// Make sure that we want to delete the hub data.
	if ( !isset($delete) ) {
		$sql = "SELECT * FROM groups WHERE gid = ('$gid')";
		$rs = mysql_query($sql) or die ("Query failed");
		$row = mysql_fetch_array($rs);
		echo "Are you sure you want to delete <b>".$row["groups"]."</b><br /><br />
		<input type=button value='No' id='fno' onClick=\"parent.location='javascript:self.history.back()'\" tabindex='1'>
		<input name='Yes' type='submit' id='fyes' onClick=\"parent.location='?title=delete&delete=yes&gid=".$row["gid"]."'\" class='button'  tabindex='2' value='Yes' />
		";
		// Close DB connection
	}

	// If delete is set to "yes" then delete the data
	if ( isset($delete) ) {
		// Update addressbook GID so we dont loose any groups
		$query = "UPDATE addressbook SET gid='1' WHERE gid=$gid";
		$result = mysql_query($query);		
		// Delete the GID from the groups DB once the addressbook GID has been updated.
		$query = "DELETE FROM groups WHERE gid=$gid";
		$result = mysql_query($query);	
		echo "The data has been deleted.<br><br>
		<input type=button value=\"Back\" id='fback' onClick=\"parent.location='index2.php?title=profile'\" tabindex=\"1\">
		";
		// Close DB connection
	}
}
?>
Return current item: Php AddressBook 2