nikhar021 Posted April 18, 2008 Share Posted April 18, 2008 when i use exit in an if condition then the code following all the if-elseif conditions is not running wat should i do????? Quote Link to comment https://forums.phpfreaks.com/topic/101754-exit-if-condition/ Share on other sites More sharing options...
jonsjava Posted April 18, 2008 Share Posted April 18, 2008 we need to see the code before we can give good advice. The most likely reason I can think of though is you did something like this: if ($var = "this") instead of this: if ($var == "this") Quote Link to comment https://forums.phpfreaks.com/topic/101754-exit-if-condition/#findComment-520579 Share on other sites More sharing options...
phpretard Posted April 18, 2008 Share Posted April 18, 2008 Post the code Quote Link to comment https://forums.phpfreaks.com/topic/101754-exit-if-condition/#findComment-520581 Share on other sites More sharing options...
nikhar021 Posted April 18, 2008 Author Share Posted April 18, 2008 if(isset($_POST['r8'])) { $count=8; exit; } elseif(isset($_POST['r7'])) { $count=7; exit; }----------------------upto r1 code here does not execute Quote Link to comment https://forums.phpfreaks.com/topic/101754-exit-if-condition/#findComment-520584 Share on other sites More sharing options...
kenrbnsn Posted April 18, 2008 Share Posted April 18, 2008 "exit" stops the script. Take it out. Ken Quote Link to comment https://forums.phpfreaks.com/topic/101754-exit-if-condition/#findComment-520588 Share on other sites More sharing options...
nikhar021 Posted April 18, 2008 Author Share Posted April 18, 2008 then wat should i use in place of exit since if i do not exit then count will be assigned a lower even when an upper value is valid Quote Link to comment https://forums.phpfreaks.com/topic/101754-exit-if-condition/#findComment-520591 Share on other sites More sharing options...
jonsjava Posted April 18, 2008 Share Posted April 18, 2008 don't do it that way. do it something like this: $value = $_POST['value'] if ($value == 1){ $count = 1; } elseif ($value == 2){ $count = 2; } so on and so forth... then just change your form to a select area, and have it post it <select name = "value"> <option value='1'>1</option> <option value='2'>2</option> Quote Link to comment https://forums.phpfreaks.com/topic/101754-exit-if-condition/#findComment-520595 Share on other sites More sharing options...
nikhar021 Posted April 18, 2008 Author Share Posted April 18, 2008 i need info from the user how can i use select then Quote Link to comment https://forums.phpfreaks.com/topic/101754-exit-if-condition/#findComment-520598 Share on other sites More sharing options...
jonsjava Posted April 18, 2008 Share Posted April 18, 2008 i need info from the user how can i use select then I'm sorry, it looked like set input. (If it is this, then do this, if this, then do that). Please explain. Quote Link to comment https://forums.phpfreaks.com/topic/101754-exit-if-condition/#findComment-520601 Share on other sites More sharing options...
nikhar021 Posted April 18, 2008 Author Share Posted April 18, 2008 r8 is the name of the field which the user enters...... i want to know the no of fields he enters info in .......simple Quote Link to comment https://forums.phpfreaks.com/topic/101754-exit-if-condition/#findComment-520607 Share on other sites More sharing options...
jonsjava Posted April 18, 2008 Share Posted April 18, 2008 <?php $counter = implode($_POST); foreach($_POST as $key => $value) { if ($value != "Submit"){ /* Don't count the submit button */ $count++ } } And now for an explanation (sorry for the delay on this part): the code takes all the data a user posts, and adds it to an array (counter). Next, it checks each value in the array, and so long as it is not the value for the submit button, it counts it. Quote Link to comment https://forums.phpfreaks.com/topic/101754-exit-if-condition/#findComment-520610 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.