note 50451 deleted from control-structures.for by nlopess

From: Date: Tue, 01 Mar 2005 15:22:06 +0000
Subject: note 50451 deleted from control-structures.for by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-85720@lists.php.net to get a copy of this message
Note Submitter: Benito Johotoson Reason: useless ---- <? ///////////////////////////////////////////////////////////////////// /*This script is for incrimenting or decrementing between page loads. The problem occurs when we try to pass a php variable value after a POST submission. All PHP variables are dropped upon reload of the page and only that data which POST passes can move between sessions: exluding cookies that is. We work around this by using a counter and incrimenting the POST name with our PHP counter variable. This is kind of like leaving a note for ourselves. When the page reloads the first thing we do is use a for loop to check the POST variable's value. When we find it we initialize our PHP variables based upon this.*/ ///////////////////////////////////////////////////////////////////// for($a=0; $a<100; $a++) { if($_POST['inc' . $a]) { $i=$a+1; } if($_POST['dec' .$a]) { $i=$a-1; } } if($i<1) { $i=0; } ?> <form method="post" action="incl.php"> Number of Items<input value=<?print $i?> type="Text" name="title"><br> <TR<td><td><input type="Submit" name="inc<?print $i;?>" value="Add an item <? print $i;?>"><br> <TR<td><td><input type="Submit" name="dec<?print $i;?>" value="Remove an item <? print $i;?>"><br>

« previous php.notes (#85720) next »