PakiGangsta Posted June 8, 2006 Share Posted June 8, 2006 Alright i have this as my code and it only deletes only one and that is it.[code]$box=$HTTP_POST_VARS['pm'];$box_count=count($box);foreach ($box as $dear) {$del="DELETE FROM PM where ID='$dear'";mysql_query($del) or die("Could not delete message");echo "All selected private messages are deleted.";include 'footer.php';die();}[/code] Please help me. Link to comment https://forums.phpfreaks.com/topic/11455-need-help-about-more-than-1-deletion/ Share on other sites More sharing options...
poirot Posted June 8, 2006 Share Posted June 8, 2006 1. This should be outside of the foreach loop.[code]echo "All selected private messages are deleted.";include 'footer.php';die();[/code]Meaning after 1 message is deleted, the script aborts. Remove it from the loop.2. If it deletes 1 message, it should be OK as soon as the die() is removed from the loop; but if that still doesn't work, check if your checkbox have the correct name (like pm[]) and that it gives you correctly an array.3. $HTTP_POST_VARS is deprecated. Use $_POST instead Link to comment https://forums.phpfreaks.com/topic/11455-need-help-about-more-than-1-deletion/#findComment-43020 Share on other sites More sharing options...
PakiGangsta Posted June 8, 2006 Author Share Posted June 8, 2006 so shoul i take out the die cause wouldnt that stop the query to do it again or no[!--fonto:Times New Roman--][span style=\"font-family:Times New Roman\"][!--/fonto--] fixed it :) thanks :D[!--fontc--][/span][!--/fontc--] Link to comment https://forums.phpfreaks.com/topic/11455-need-help-about-more-than-1-deletion/#findComment-43022 Share on other sites More sharing options...
poirot Posted June 8, 2006 Share Posted June 8, 2006 The query shouldn't be executed more than once; there is no need to abort the execution of the script. Remember that die() will abort the entire script's execution. Link to comment https://forums.phpfreaks.com/topic/11455-need-help-about-more-than-1-deletion/#findComment-43025 Share on other sites More sharing options...
PakiGangsta Posted June 8, 2006 Author Share Posted June 8, 2006 [!--quoteo(post=381231:date=Jun 7 2006, 08:01 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 7 2006, 08:01 PM) [snapback]381231[/snapback][/div][div class=\'quotemain\'][!--quotec--]The query shouldn't be executed more than once; there is no need to abort the execution of the script. Remember that die() will abort the entire script's execution.[/quote] fixed it and thanks for all the help i knewed it was the problem in die(); Link to comment https://forums.phpfreaks.com/topic/11455-need-help-about-more-than-1-deletion/#findComment-43029 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.