Search code examples
phpgetresponsegetresponsestream

PHP dropdown value need to save


I'm having trouble with the current PHP dropdown and I'm posting this to get some shine of light.

Here's the HTML dropdown code

<select name="campaign_id">
    <?php foreach ( $campaigns as $campaignID => $value) { ?>
    <option value="<?php echo $campaignID;?>"><?php echo $value->name;?></option>    
    <?php } ?>
</select>

This value will be fetch from the GetResponseAPI.

$campaigns = empty value.
$campaignID= list of campaign ID but not in string
$value->name = I'm getting the campaign name [I need the string value of the campaign]

I also save the dropdown value to initialize with the following:

$drop = $_POST['campaign_id'];

Now $drop only carry the campaign token ID for example 9h6R but when I echo $value->name , i get the campaign name such as "Carrols_Campaign".

Is it possible for me to save the campaign name from the dropdown list when the user made his choice.

Is there any other method where I can save the campaign name which occurs in the array?? Thanks in advance


Solution

  • I use the API function from get response

    $result =  $api->getCampaigns('EQUALS',$drop);
    

    where the dropdown value looks something like this:

    <option value="<?php echo $value->name;?>"><?php echo $value->name;?></option>   
    

    because when I use the option value for $value->name; and then i echo again the same value to know the name of value. So i saved the value and use it @ $results.