how to input multiple (dynamic)values in an array
Results 1 to 7 of 7

Thread: how to input multiple (dynamic)values in an array

  1. #1
    Junior Member
    Join Date
    Sep 2007
    Posts
    26

    how to input multiple (dynamic)values in an array

    Hi,

    This code is within a loop where i am selecting (multiple) country and specialty from database.
    In the table with other data pulling, i want to input some values from the user under this code and i am performing some formula on the $sample in Sends Necessary.php file
    PHP Code:
      $sample=$_GET['sample'];
      echo 
    "<td>";
    echo 
    "<form action=\"Sends Necessary.php\" method=\"GET\">
    <input type='number' name='sample' value='
    $sample'>";
       echo 
    "</td>";
                    
     
    $_SESSION["sample"]=$sample
    Now my problem is when it is single selection of country and specialty then this works but when i select multiple values then it only remember the last value input.
    Please help me with this.


    Many Thanks

  2. #2
    Senior Member
    Join Date
    Sep 2005
    Location
    Champaign, IL
    Posts
    130
    It's hard to tell exactly what you're looking for from the limited code you provided, but I have a feeling you are trying to do something similar to checkboxes. Here's an example of what to do for checkboxes (http://www.webmasterworld.com/forum88/11963.htm). Basically, if you have a form with multiple inputs with the same name:
    PHP Code:
     <INPUT type="checkbox" name="assistivetech[]" value="Interpretype">Interpretype<BR>
    <
    INPUT type="checkbox" name="assistivetech[]" value="Large Print Internet Monitor">Large Print Internet Monitor<BR>
    <
    INPUT type="checkbox" name="assistivetech[]" value="Video Eye">Video Eye<BR
    Then you can display them like this:
    PHP Code:
     for ($i=0$i<count($_POST['assistivetech']); $i++){
    $assistivetech_req addslashes($_POST['assistivetech'][$i]);
    //do this
    //do that
    }//end loop 
    It might not apply directly to what you're doing, but you can probably change your form to work this way. If this doesn't help, you need to post more code.
    Nothing really there yet, but yeah, one day...outby9

  3. #3
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,911
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  4. #4
    Junior Member
    Join Date
    Sep 2007
    Posts
    26
    No ,I am not trying to input checkboxes but like as an exapmle above of coding ,how can i input 3 times value in the above code as an exapmle in one row, user input
    34 in the text and in the other row user input 67,when i perform operations on $sample it only remembers 67 and display 67 in both rows and in the results for 67 on both rows.

    but when i perform it for 1 row it works.
    so i want to store more then 1 row input into $sample

  5. #5
    I code 4 beer ... bogu's Avatar
    Join Date
    Nov 2002
    Location
    Romania
    Posts
    1,743
    Did you look over the Weedpacket`s post?
    /**
    * The answer is so obvious, duh!
    * It's like, whatever ...
    *
    * If your problem has been solved, PLEASE click the RESOLVED LINK under "Thread Tools"
    */

  6. #6
    Junior Member
    Join Date
    Sep 2007
    Posts
    26
    Yes ,but my questions is not clear i think, let try once again what i am trying to do...

    Suppose from this code
    PHP Code:
    echo "<form action=\"Sends Necessary.php\" method=\"GET\"> 
    <input type='number' name='sample' value='
    $sample'>"
       echo 
    "</td>"
    I am asking for a textbox of type number right, but i am only getting one variable through $sample, due to which when i input any number it remembers that but

    hidden part is i am pulling this in the loop ,before asking this i am selecting a country and specialty and when i select only one country and one specialty it pulls the above requested textbox once and everything works fine,
    but
    when i pull more then one country and specialty then i get that text box displayed as manytimes as the selection ..suppose i selected US and Canada with Dentist then my results will be
    Code:
    US                Dentist  Textbox1 (i requested)
    Canada           Dentist  Textbox2 (i requested)
    so i am doing some mathematical operation on these textboxes but when i run Go the end of this form then i remembers only value entered in textbox2 and give results for that in both ......


    i know i should be calling array in the form but that is what i don't know as i am new ........

    as well as i am not trying to input more then 1 value in 1 textbox but i was calling one texbox and that is taking one variable i should be calling instaed a array that can store my 2nd value in 2nd textbox
    Last edited by siyaverma; 02-29-2008 at 02:48 PM.

  7. #7
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,911
    Because all of the text boxes have the same name.

    Quote Originally Posted by siyaverma
    i know i should be calling array in the form but that is what i don't know as i am new ........
    Yes, you do need to have the results returned in an array; see again the link I provided. That tells you how to make several fields with the same name into an array.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

Thread Information

Users Browsing this Thread

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

Posting Permissions

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