www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] fetch respective values from two correlated array

Threaded View

  1. #1
    Join Date
    May 2013
    Posts
    11

    resolved [RESOLVED] fetch respective values from two correlated array

    PHP Code:
    <?php

    $meals_outside_types 
    = array('Breakfast','Lunch','Dinner','Evening snacks','Any others');

    if(
    $_POST['submit'] == "Submit")
    {
    $meals_outside $_POST['meals_outside'];
    $meals_outside_string implode("##"$meals_outside);
    $meals_outside_descr $_POST['meals_outside_descr'];
    $meals_outside_descr_string implode("##"$meals_outside_descr);

    }

    ?>
    <form method="POST" action="<?php echo $_SERVER['PHP_SELF'?>" name="abc" >

    <div class="form-row">
    <label for="fname" class="form-label" >Do you consume any of the meals outside, if yes please Click (?) & also mention the frequency & specify what you eat : <span class="required">* </span> </label>

    <? 
    $meals_outsidecount
    =0;

    for(
    $i 0$i count($meals_outside_types); $i++)
    {
        
    $mealsoutside explode("##",$meals_outside_string);

        if (
    $mealsoutside[$meals_outsidecount] == $meals_outside_types[$i])
        {       
        
    ?>
        <input type="checkbox" name="meals_outside[]" id="<?=$meals_outside_types[$i];?>" value="<?=$meals_outside_types[$i]; ?>" checked="checked" ><?=$meals_outside_types[$i];?>

            <textarea class="itemlrg" name="meals_outside_descr[]" id="<?=$meals_outside_descr[$i];?>" cols="30" rows="3"><?if($meals_outside_descr[$i] != "")  { echo trim($meals_outside_descr[$i]); }else{ }?></textarea><br />
        <?
                                                                     $meals_outsidecount
    ++;
        }
        else
        {
        
    ?>
        <input type="checkbox" name="meals_outside[]" id="<?=$meals_outside_types[$i];?>" value="<?=$meals_outside_types[$i]; ?>" ><?=$meals_outside_types[$i];?>

        <textarea class="itemlrg" name="meals_outside_descr[]" id="<?=$meals_outside_descr[$i];?>" cols="30" rows="3"><?if($meals_outside_descr[$i] != "") { echo trim($meals_outside_descr[$i]); }else{ }?></textarea><br />
        <?
        
    }
        }

    ?>



    </div>
    <input type="submit" name="submit" value="Submit" class="submitbtn" />   

    </form>
    In this program I want to map two related arrays one array is of check boxes (breakfast,lunch,..) and another array is of textarea which will be value for first array respectively I want to fetch and respective values. suppose user keeps braeakfast texarea blank then i should get blank for breakfast and next value for lunch.
    Last edited by NogDog; 05-27-2013 at 02:27 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles