Re: Help Adjusting Fields per Date

From: Date: Fri, 03 Nov 2000 09:18:35 +0000
Subject: Re: Help Adjusting Fields per Date
Groups: php.general 
Request: Send a blank email to php-general+get-23532@lists.php.net to get a copy of this message
Addressed to: Christopher King <chris@create4u.com> php-general@lists.php.net ** Reply to note from Christopher King <chris@create4u.com> Thu, 02 Nov 2000 13:09:55 +0000 > > I am making this happen myself but it is complicated and I could use some > help. If anyone knows of an example script somewhere or if they can just > help me I will kiss their ass. > > There are more fields than this and other things going on but in a > nutshell my problem looks like this: > > ******************* > > User submits form with fields Material#, Weight, Date. > > Weight can only be 1200lbs per day. > If user submitted form exceeds calculation for day's weight a new record > is created with the same Material#, Difference of Weight and next days > Date. OK, try this... When you first hit this page, it will have todays date filled in, with Material and Weight blank. When you click the submit button it checks to see if weight is > 1200. If it is, it repaints the form with the same material, the next date and the remaining weight. If the weight is less than 1201 it repaints itself with material blanked out, and the day set back to today. You still have to handle error checking, the process of creating the order, and determining the value of Today. If you don't use a day counter for Day, you may have to do something besides adding 1 to Day to get NextDay. Note this program calls itself when the submit button is hit. You will need a link on the page to break out of the loop. To start a cycle of adding entries, just hit the page, it will initialize itself. -------------------------------------------------- <HTML> <BODY> <? # # Incoming variales from the form: # $Material = desired material# # $Day = desired day. # $Weight = desired amount # # $Action : Set to 'Submit' if the page is called # from itself, by clicking the [Submit] button. # $Today = 3; ######################################### # # function CreateOrder # function CreateOrder( $Material, $Day, $Weight ) { echo "Create Order - Material: $Material ", "Day: $Day Weight: $Weight<BR><BR>\n"; } ######################################### # # m a i n # if( 'Submit' == $Action ) { # User hit submit button if( $Weight > 1200 ) { # More than 1200 desired # Create 1200 and current date. $Remaining = $Weight - 1200; $Weight = 1200; $NextDay = $Day + 1; $Message = 'You last order was more than 1200, please hit' . '[Submit] again to schedule the remaining weight.'; } else { # 1200 or less, ok for one day $Remaining = 0; $NextDay = $Today; # need to figure out what today is. $Message = 'Please enter your next order'; } CreateOrder( $Material, $Day, $Weight ); if( 0 == $Remaining ) { # This was the last one so clear out $Material = ''; # Material field } } else { # Called from a link, initalize values. $Material = ''; $NextDay = $Today; $Remaining = ''; $Message = 'Please enter your first order' } ?> <FORM action="<?=$PHP_SELF?>" method="POST"> <CENTER> <H1>Create Orders</H1> <H3><?="$Message?></H3> <BR><BR> <TABLE> <TR> <TD> Material: </TD> <TD> <INPUT Type=Text Name="Material" Value="<?=$Material?>"><BR> </TD> </TR> <TR> <TD> Day: </TD> <TD> <INPUT Type=Text Name="Day" Value="<?=$NextDay?>"><BR> </TD> </TR> <TR> <TD> Weight: </TD> <TD> <INPUT Type=Text Name="Weight" Value="<?=$Remaining?>"><BR> </TD> </TR> </TABLE> <INPUT Type="Submit" Name="Action" Value="Submit"> </CENTER> </FORM> </BODY> </HTML> -------------------------------------------------- Rick Widmer Internet Marketing Specialists www.developersdesk.com

« previous php.general (#23532) next »