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. Link to comment https://forums.phpfreaks.com/topic/206748-counter-help/ 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. Link to comment https://forums.phpfreaks.com/topic/206748-counter-help/#findComment-1081232 Share on other sites More sharing options...
nblackwood Posted July 5, 2010 Author Share Posted July 5, 2010 yes...sorry Link to comment https://forums.phpfreaks.com/topic/206748-counter-help/#findComment-1081234 Share on other sites More sharing options...
travo1992 Posted July 5, 2010 Share Posted July 5, 2010 Dont be. Did it do the job? Link to comment https://forums.phpfreaks.com/topic/206748-counter-help/#findComment-1081236 Share on other sites More sharing options...
nblackwood Posted July 5, 2010 Author Share Posted July 5, 2010 no, it still counts negative values Link to comment https://forums.phpfreaks.com/topic/206748-counter-help/#findComment-1081276 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. Link to comment https://forums.phpfreaks.com/topic/206748-counter-help/#findComment-1081308 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.