maintaining relation while POSTing and while fetching.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #16
    A little example using associtive arrays
    [PHP]$assocArray = array();
    $nBoxes = 3;
    for($c=0;$c<$nB oxes;$c++)
    {
    $name = 'box'.$c; creates a string called 'box' with a numeric suffix
    $value = 'Any string '.1;

    $assocArray[$name] = $value;
    echo '<input type="textbox" name="'.$name.' id="'.$c.'value ="'.$value.' >';
    }
    //Creates an array such
    assocArray ('box0'=> 'Anystring 0','box1'=> 'Anystring 1','box2'=> 'Anystring 2')
    //

    //Read array
    foreach($assocA rray as $key=>$value)
    {
    echo 'Name = '.$key;
    echo ' Value = '.$value.'<br>' ;
    }
    //Will output
    Name = box0 value = Anystring 0
    Name = box1 value = Anystring 1
    Name = box2 value = Anystring 2
    //Or at least it should do [/PHP]

    Comment

    • rpnew
      New Member
      • Aug 2007
      • 189

      #17
      Originally posted by code green
      A little example using associtive arrays
      [PHP]$assocArray = array();
      $nBoxes = 3;
      for($c=0;$c<$nB oxes;$c++)
      {
      $name = 'box'.$c; creates a string called 'box' with a numeric suffix
      $value = 'Any string '.1;

      $assocArray[$name] = $value;
      echo '<input type="textbox" name="'.$name.' id="'.$c.'value ="'.$value.' >';
      }
      //Creates an array such
      assocArray ('box0'=> 'Anystring 0','box1'=> 'Anystring 1','box2'=> 'Anystring 2')
      //

      //Read array
      foreach($assocA rray as $key=>$value)
      {
      echo 'Name = '.$key;
      echo ' Value = '.$value.'<br>' ;
      }
      //Will output
      Name = box0 value = Anystring 0
      Name = box1 value = Anystring 1
      Name = box2 value = Anystring 2
      //Or at least it should do [/PHP]

      hmm well thats an useful example..

      Thanks,
      RP

      Comment

      Working...