Just coding a lil game, but what i want this to do is allow users to add "enemies" to there list, but i also want them to be able to remove enemies. The way i have it set up right now is when they click the [X] that displays above the enemy name is that it deletes all the enemies What i want it to do is when they click the [X] is just delete THAT entry not every row in the database. Anyone help? <?php $sql = mysql_query("SELECT * FROM enemy"); while($row = mysql_fetch_array($sql)) { $ename = $row['ename']; $evill = $row['evill']; $delete = mysql_query("DELETE FROM enemy WHERE evill='$evill'"); echo "<b><a href='?$delete'>[X]</a></b>"; echo "<br /><b>Enemy:</b> " . $ename; echo "<br /><b>Village:</b> " . $evill; echo "<br />"; echo "<br />"; } ?> PHP: It displays like this [X] Enemy: Enemies Name Village: Enemies Village .etc Basicly just keeps going as far as they add entries.
Just thought i'd add onto what Martin said, you'll probably want to change deleting $evil to $ename so that's it's removing the person rather than the entire village. Also make sure you sanitize the input!
probably worth checking it's the user themselves doing the deleting as well. So add in user_id and ename to the delete from enemy query and all should be good
another thing you will want to do is associate the enemy or allies in the DB to that specific person that added them or is deleting them. as numerous people will have same or similar enemies, or allies so have it store the persons id that is adding them as a enemies or allies then you can be more specific when deleting them so it dont delete all at one time.