gsnedders
03-21-2004, 05:26 PM
I want to have a value, starting at zero, so if radio button value="B" id="one" is checked then the value goes up one, how can this be done?
|
||||
Form questiongsnedders 03-21-2004, 05:26 PM I want to have a value, starting at zero, so if radio button value="B" id="one" is checked then the value goes up one, how can this be done? missing-score 03-21-2004, 05:38 PM Please could you give some more info! Do you want the value to be saved on the server? Do you want it in a textfile or DB, or a session? gsnedders 03-21-2004, 05:44 PM A text file, let's call it saveto.txt here (another part of the script will control that). missing-score 03-22-2004, 07:24 AM Try something along the lines of: <?php $file = "saveto.txt"; $fp = fopen($file, 'r'); while(!feof($fp)){ $str_val = fgets($fp, 32); // not expecting the file do contain more than 32 bytes (32 digit number) } fclose($fp); settype($str_val, 'int'); if($_POST['one'] == 'B'){ $str_val++; $fw = fopen($file, 'w'); fputs($fw, $str_val); fclose($fw); } ?> gsnedders 03-22-2004, 07:25 PM What is that w, r and int for? missing-score 03-22-2004, 07:28 PM r and w are file handling modes, see http://www.php.net/fopen. int tells the script to make sure the result is an integer, so we can preform mathmatical operations on it (see http://www.php.net/settype) gsnedders 03-22-2004, 07:57 PM What does it put in the document? |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum