crossfuse Posted April 28, 2009 Share Posted April 28, 2009 ok let me show my code before i explain what i'm doing <html> <body> <h2 align ="center">Enter Numbers!</h2> <form method="number.php" action="post"> #1 <input type="text" size="4" maxlength="7" name="num1"><br> #2 <input type="text" size="4" maxlength="7" name="num2"><br> #3 <input type="text" size="4" maxlength="7" name="num3"><br> #4 <input type="text" size="4" maxlength="7" name="num4"><br> #5 <input type="text" size="4" maxlength="7" name="num5"><br> #6 <input type="text" size="4" maxlength="7" name="num6"><br> #7 <input type="text" size="4" maxlength="7" name="num7"><br> #8 <input type="text" size="4" maxlength="7" name="num8"><br> <br><input type="Submit" value="Submit"> <input type="Reset" value="Reset"> </form> </body> </html> <?PHP $numbers[] = '$num1'; $numbers[] = '$num2'; $numbers[] = '$num3'; $numbers[] = '$num4'; $numbers[] = '$num5'; $numbers[] = '$num6'; $numbers[] = '$num7'; $numbers[] = '$num8'; rsort($numbers); $big=max($numbers); $small=min($numbers); print ("The biggest number is $big, and the smallest number is $small."); ?> ok well i'm trying to make a form where a user can enter numbers and the numbers come out with the average of the numbers that are typed in. i can't use the array function though because some numbers may not be filled in. i feel like i'm close to building the array, but i still am not doing it right...help?? Link to comment https://forums.phpfreaks.com/topic/155923-array-building/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 28, 2009 Share Posted April 28, 2009 Make the form field name an array - http://www.php.net/manual/en/faq.html.php#faq.html.arrays Link to comment https://forums.phpfreaks.com/topic/155923-array-building/#findComment-820787 Share on other sites More sharing options...
crossfuse Posted April 28, 2009 Author Share Posted April 28, 2009 um well i'm not understanding how to get the '$num' variables to work in the arrays Link to comment https://forums.phpfreaks.com/topic/155923-array-building/#findComment-820792 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.