madmenyo Posted May 20, 2010 Share Posted May 20, 2010 Hey, for each loop $slotcounter returns me "4" .... wich is weird because i do get 4 buttons displayed. print $_POST['wslot']; return only slot4 to mo wichever button i click. I need it to be button 1,2,3,4 <?php if (isset($_POST['useweapon'])) { print $_POST['useweapon']; echo "</br>"; print $_POST['wslot']; } } ?> <form action="" method="post"> <?php $slotcounter = 1; //while ($slotcount['weaponslots'] >= $slotcounter) while ($slotcounter <= 4) { ?> <input type="hidden" value="slot<?php echo $slotcounter;?>" name="wslot"> <INPUT TYPE="image" SRC="images/slot<?php echo $slotcounter;?>.jpg" HEIGHT="11" WIDTH="11" BORDER=0 ALT="^" name="useweapon" value="<?php echo $weaponrows['weaponID'];?>"> <?php $slotcounter++; } ?> </form> Link to comment https://forums.phpfreaks.com/topic/202329-while-loop-inside-while-loop/ Share on other sites More sharing options...
smarble53 Posted May 20, 2010 Share Posted May 20, 2010 It seems to be working for me. BUUUT... <?php if (isset($_POST['useweapon'])) { print $_POST['useweapon']; echo "</br>"; print $_POST['wslot']; } } ?> Why is there a second curly brace after this? is it in another if or while loop? Link to comment https://forums.phpfreaks.com/topic/202329-while-loop-inside-while-loop/#findComment-1060906 Share on other sites More sharing options...
madmenyo Posted May 20, 2010 Author Share Posted May 20, 2010 I actually had to reverse $slotcounter and $weaponrows for it to work, i don't know why but it works like it should. i speneded like 2 hours on this The bracket is from another statement, i shouldn't have included that in the code sorry, Link to comment https://forums.phpfreaks.com/topic/202329-while-loop-inside-while-loop/#findComment-1060907 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.