dsonesuk Posted October 19, 2014 Share Posted October 19, 2014 OK, good luck with that. Link to comment Share on other sites More sharing options...
j.silver Posted October 22, 2014 Author Share Posted October 22, 2014 Many thanks niche and dsonesuk for your sincere efforts and help. Link to comment Share on other sites More sharing options...
dsonesuk Posted October 23, 2014 Share Posted October 23, 2014 :-) <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>show html on page using php</title> <style type="text/css"> </style> </head> <body> <?php $checked = ''; $sk = array("Saskatoon", "Regina", "Moose Jaw", "Prince Albert"); if (isset($_POST['currentArray']) && !empty($_POST['currentArray']) && count(unserialize($_POST['currentArray'])) > count($sk)) { $sk = unserialize($_POST['currentArray']); } if (isset($_POST['new_option']) && !empty($_POST['new_option'])) { $multi_value = explode(",", trim($_POST['new_option'])); foreach ($multi_value as $array_item) { if (!in_array(ucwords($array_item), $sk)) array_push($sk, trim(ucwords($array_item))); } } if (isset($_POST['pre_or_html']) && !empty($_POST['pre_or_html'])) { $checked = ' checked="checked"'; } $currentArray = $sk; echo count($currentArray); if (isset($_POST['currentArray'])) { echo '<br>values: '; print_r($currentArray); } sort($sk); ?> <form method="post"> <input type="hidden" value='<?php echo serialize($currentArray); ?>' name="currentArray"> <label>HTML select</label><input type="checkbox" <?php echo $checked; ?> name="pre_or_html" value="html"> <label>New option (separate multiple values with comma) </label><input type="text" name="new_option" value=""> <input type="submit"> </form> <?php $txt = ""; foreach ($sk as $value) { $txt.='<option value="' . $value . ',SK,Canada">' . $value . ',SK,Canada</option>' . "n"; } if (isset($_POST['pre_or_html']) && !empty($_POST ['pre_or_html'])) { echo '<select>' . $txt . '</select>'; } else { echo '<pre>' . htmlspecialchars($txt) . '</pre>'; } ?> </body></html> Link to comment Share on other sites More sharing options...
j.silver Posted October 24, 2014 Author Share Posted October 24, 2014 Dear dsonesuk,This was a first-class code. I hope one day I can gain some advanced skills in coding such as yours. Many thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now