Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2005
    Posts
    40

    Unanswered: Stuck problem...variables

    I have one var $mean and another $i.
    How can I concatenate these these two so i will have mean1 , mean2 , mean3
    with a for loop ???
    I have stuck to this...

  2. #2
    Join Date
    Feb 2004
    Posts
    533
    Quote Originally Posted by archVille
    I have one var $mean and another $i.
    How can I concatenate these these two so i will have mean1 , mean2 , mean3
    with a for loop ???
    I have stuck to this...

    $meanx = $mean . $i
    ~

    Bill

  3. #3
    Join Date
    Nov 2005
    Posts
    40
    MY MISTAKE :
    I want to pass a varible from a form :
    echo"<input name='meanx".($i+1)."' type='text' size='2' maxlength='2'/>";

    to another php page so to take $meanx1 , $meanx2 , $meanx3 ...
    i wasnt clear enough before... i am sorry

  4. #4
    Join Date
    Jan 2004
    Location
    India
    Posts
    168
    hi
    once you post the form you have the send the max value of $x as counter to the next php page.
    now int he 2nd page you have to use a for loop like this
    PHP Code:
    for($i=0;$i>$count;$i++)
    {
       
    $mean=$_POST['mean'.$i];
       echo 
    $mean;

    This will give you the result you are looking for.

    if its don't work let me know.

    Regards
    Rajesh

    Quote Originally Posted by archVille
    MY MISTAKE :
    I want to pass a varible from a form :
    echo"<input name='meanx".($i+1)."' type='text' size='2' maxlength='2'/>";

    to another php page so to take $meanx1 , $meanx2 , $meanx3 ...
    i wasnt clear enough before... i am sorry
    Freelance and Technology Consultant
    -------------------
    Dreams are for ever
    -------------------

  5. #5
    Join Date
    Feb 2004
    Posts
    533
    Here is another example that accepts either Post or Get form values and assigns them to a scaler of the same name as the controls name.
    PHP Code:
    $PARAMS = ( count$_POST ) )
                ? 
    $_POST $_GET;

    foreach(
    $PARAMS as $key=>$value) {
    $
    $key $value;
    echo 
    "var equal: $key = $value <br>";

    ~

    Bill

  6. #6
    Join Date
    Nov 2005
    Posts
    40
    Thanx rajesh it worked fine.
    I had tried eveyrthing but without the POST method.

  7. #7
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    FYI, instead of using the counter for your form names, it's much simpler to use the bracket syntax. You give each input the same name and then parse it as an array after the form has been submitted.

    http://www.eklekt.com/tutorials/tutorial.php?t=3 for an example.
    Give a man a fish and you feed him for a day. Teach a man to fish and you lose a steady customer.
    -----------
    Eclectic Web Development (under heavy construction)

Posting Permissions

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