sycoj0ker Posted January 26, 2010 Share Posted January 26, 2010 for example; $example1 = "red"; $example2 = "blue"; $example3 = "green"; $example4 = "white"; $example5 = "black"; I have 5 options in a form, one dedicated to each example (1 to 5).. I want to go to the 3rd option (which is $example3) and change it from green to grey (all the colors are in a big list), without changing any other variables from what they are already set as at a different time. help? a friend gave me this to work off but I dont know how to integrate it: fwrite($file, "$settings['example1']=\''.$_POST['Grey'].'\';'."\n"); Quote Link to comment https://forums.phpfreaks.com/topic/189861-how-to-change-one-variable-thats-in-an-array-of-10-with-a-form/ Share on other sites More sharing options...
oni-kun Posted January 26, 2010 Share Posted January 26, 2010 want to go to the 3rd option (which is $example3) and change it from green to grey You will need to provide a better example of what you are wanting to do. "Change from green to grey", You may want to look into session variables and swap it with green, thus leaving the other session 'colors' in tact. $_SESSION['color1'] = 'blue'; $_SESSION['color2'] = 'green'; $_SESSION['color1'] = 'red'; if (isset($_POST['option2'])) { $_SESSION['color2'] = 'grey'; //Or to your color table accordingly } Quote Link to comment https://forums.phpfreaks.com/topic/189861-how-to-change-one-variable-thats-in-an-array-of-10-with-a-form/#findComment-1001845 Share on other sites More sharing options...
sycoj0ker Posted January 26, 2010 Author Share Posted January 26, 2010 want to go to the 3rd option (which is $example3) and change it from green to grey What is an example of what you are wanting to do? Can you not change the ratio (button) to a different color, and use the POST values accordingly? without changing any other variables from what they are already set as at a different time. So are you wanting to update JUST the one selected to grey, and not the others? .. You're not making a whole lot of sense.. And I'd recommend using arrays, they are much more portable. http://urbandead.org/halp/home.jpg - that's the homepage, note how they all have different colors? http://urbandead.org/halp/admin.jpg - that's the admin panel, note how all the options are on ghost? ghost is the default option. http://urbandead.org/halp/output.jpg - the form values from the admin is written to a file (http://urbandead.org/danger.php - if you look at the source code note the .css classes - they are the options) I don't want to have to change all 100 options if only one box needs to be changed, I want all the form values to be saved how I set them, and not default to ghost each time because it takes 10 minutes to set them all again. I can post the source code if you need it.. that's what I mean by changing any variable that's in a big array using form options. Quote Link to comment https://forums.phpfreaks.com/topic/189861-how-to-change-one-variable-thats-in-an-array-of-10-with-a-form/#findComment-1001850 Share on other sites More sharing options...
sycoj0ker Posted January 26, 2010 Author Share Posted January 26, 2010 if ($_POST['updatenotepad']) { $updatenotepad = stripslashes(htmlspecialchars($_POST['updatenotepad'], ENT_QUOTES)); $shoutsettings ="<?php\n\$email = '$email';\n\$skinchoice = '$skinchoice';\n\$yourpassword = '$yourpassword';\n\$status = '$status';\n\$avatar = '$avatar';\n\$sig = '$sig';\n\$title = '$title';\n\$signup_ipa = '$signup_ipa';\n\$msn = '$msn';\n\$yim = '$yim';\n\$aim='$aim';\n\$icq = '$icq';\n\$www='$www';\n\$notepad = '$updatenotepad';\n\$birthday = '$birthday';\n\$postcount = '$postcount';\n?>"; $fp = fopen("./accounts/{$acfile}_user.php","w+"); fwrite($fp, $shoutsettings); fclose($fp); } and <?php $email = 'none'; $skinchoice = 'Default'; $yourpassword = ''; $status = 'Guest'; $avatar = 'blank.gif'; $sig = ''; $title = ''; $signup_ipa = 'localhost'; $msn = ''; $yim = ''; $aim=''; $icq = ''; $www=''; $notepad = 'notepad'; $birthday = ''; $postcount = '0'; ?> they are examples, but would that work if I changed all the variables how it is now? Quote Link to comment https://forums.phpfreaks.com/topic/189861-how-to-change-one-variable-thats-in-an-array-of-10-with-a-form/#findComment-1001854 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.