Jump to content

Setting a form element value = to existing array?


rbragg

Recommended Posts

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.  ;D

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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'] );

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.