rbragg Posted June 6, 2008 Share Posted June 6, 2008 Is it possible to set a form element value to an existing array? For example, I have an array called $app: <?php while (ocifetch($stmt1)) { $app = ociresult($stmt1, "FIELD"); # this is an array populated by a query results echo "<input type='checkbox' name='reminders[]' value='" . $app . "'>"; } ?> Ultimately, I would like the values in $app to be added to the reminders[] array. Is this possible or can someone divulge a way to do this? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
amites Posted June 6, 2008 Share Posted June 6, 2008 something like a foreach loop foreach ($app as $row) { echo "<input type=\"checkbox\" name=\"reminders[]\" value=\"".$row['val']."\">"; } ??? Quote Link to comment Share on other sites More sharing options...
rbragg Posted June 6, 2008 Author Share Posted June 6, 2008 Thanks for your reply. I don't want to echo the form element for every value in $app. I would like to set the form element = to $app. Quote Link to comment Share on other sites More sharing options...
amites Posted June 6, 2008 Share Posted June 6, 2008 I'm taking a guess here that you want to set multiple values to a single radio button? easiest way would be to echo them out as a comma separated value and then explode on processing, if thats not it, then I'm not sure what your trying to do Quote Link to comment Share on other sites More sharing options...
discomatt Posted June 6, 2008 Share Posted June 6, 2008 Best way to do this IMO is to store $app in a session to carry it to the next page... use the checkbox as a boolean <input type="checkbox" name="useApp" value="1"> Use $app? Then check for it if ( isset( $_POST['useApp'] ) ) print_r( $_SESSION['app'] ); Quote Link to comment 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.