nblackwood Posted July 5, 2010 Share Posted July 5, 2010 Hey all. I have a counter i developed. Everything works well, except when the counter reaches 0 when counting backwards, I need it to stop it doesn't. It just continues into the negative values. Here is my code: <?php $AddFields = $_SESSION['NumFields']; $RemoveFields = $_SESSION['NumFields']; if(isset($_POST['Add'])) { $AddFields = $_SESSION['NumFields'] ++; $TotalFields = $AddFields +1; } if(isset($_POST['Remove'])) { $RemoveFields = $_SESSION['NumFields'] --; $TotalFields = $RemoveFields -1; } ?> Help is appreciated. Quote Link to comment Share on other sites More sharing options...
travo1992 Posted July 5, 2010 Share Posted July 5, 2010 Try if(isset($_POST['Remove'])&&$TotalFields>=0) Im assuming that TotalFields was th variable you were talking aout. Quote Link to comment Share on other sites More sharing options...
nblackwood Posted July 5, 2010 Author Share Posted July 5, 2010 yes...sorry Quote Link to comment Share on other sites More sharing options...
travo1992 Posted July 5, 2010 Share Posted July 5, 2010 Dont be. Did it do the job? Quote Link to comment Share on other sites More sharing options...
nblackwood Posted July 5, 2010 Author Share Posted July 5, 2010 no, it still counts negative values Quote Link to comment Share on other sites More sharing options...
nblackwood Posted July 5, 2010 Author Share Posted July 5, 2010 Figured it out. I wasn't unsetting my variable and session. Thanks for the help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.