Minase Posted August 4, 2008 Share Posted August 4, 2008 hy there i do have a HTML select form <form action="123.php" method="POST"> <select name="test" size="1" class="input"> <option value="1">10 minutes</option> <option value="2">20 minutes</option> <option value="3">30 minutes</option> <option value="4">40 minutes</option> <option value="5">50 minutes</option> <option value="6">60 minutes</option> </select> <input type="submit" class="input" value="send"> </form> in table users i have defined the used time all users have in total 60 minutes of fighting in that column (lets say i define it in variable $a) if $a = 1 the form to display just the first 5 options from 1-5,excluding the 6 one if $a = 2 from 1-4 display only and so on. i can do this with if statement ,but i want an loop thing,not lots of IF. thanks Link to comment https://forums.phpfreaks.com/topic/118074-solved-select-form-and-php/ Share on other sites More sharing options...
JasonLewis Posted August 4, 2008 Share Posted August 4, 2008 $minutes = array("10","20","30","40","50","60"); $a = 1; $options = ""; for($i = 0; $i < 6 - $a; $i++){ $options .= "<option value='".($i+1)."'>{$minutes[$i]}</option>"; } Not tested. Link to comment https://forums.phpfreaks.com/topic/118074-solved-select-form-and-php/#findComment-607425 Share on other sites More sharing options...
Minase Posted August 4, 2008 Author Share Posted August 4, 2008 the hard problems have an easy solve.thanks Link to comment https://forums.phpfreaks.com/topic/118074-solved-select-form-and-php/#findComment-607433 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.