Results 1 to 5 of 5

Thread: $_get

  1. #1
    Join Date
    Feb 2007
    Posts
    26

    Unanswered: $_get

    Hi,

    i have something like this in my html form:
    Code:
    <td>
      <input type="checkbox" name="medicalType[]" id="medicalType" value="<?php echo $medicalName?>"> <?php echo $medicalName?> <br/>
    </td>
    <td>
      Rp <input type="text" name="<?php echo $medicalName." price" ?>" value= "<?php echo $price ?>" class= "textBox"><br/>
    </td>
    i would like to retrieve the price from the text field that is checked by the checkbox, so i do something like this in my action page:

    PHP Code:
    $medicalType$_GET['medicalType'];
    $query_med_name"select distinct mt.medicalName from medicalType mt, appointment a, staff s, hasMedical hm where a.appId= '$appId' and a.staffId= s.staffId and s.staffId= hm.staffId and hm.medicalId= mt.medicalId";
    $result_med_namesafe_query($query_med_name);
    while (list(
    $medicalName)= mysql_fetch_array($result_med_name))
    {
        
    $name$medicalName." price";
            
    str_replace (" """$name)= $_GET[$name];    

    it doesn't work, i know i have a problem with the $_GET because when i try to echo it, it returns nothing T__T
    can anyone help me with this problem please?
    thank's for your attention

  2. #2
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    You need $_GET['{$name}'] ... it needs to be in inverted commas, just to be sure.
    Echo out each $name variable to see what it's giving you.
    And what on earth does this do :
    str_replace (" ", "", $name)= $_GET[$name];

    You haven't assigned str_replace to anything... more importantly each time you iterate over the loop you are reassigning $name to something different.

    What is your query supposed to return?

    By the looks of it you're after $_GET['someinputname']... so for a simple test just put echo $_GET['someinputname'] on the next page to make sure you are passing things across correctly.

  3. #3
    Join Date
    Feb 2007
    Posts
    26
    HI,
    thanks a lot for your reply ..
    i did $_GET['{$name}'] but it still doesn't work =)

    PHP Code:
    $name$medicalName." price";
    echo 
    $name
    when i echo the $name, it gives me the correct value.. but when i try to put the $name along in the $_GET['{$name}'], it return nothing when i echo it..
    i want to get the name of the textfield from the previous page dynamically, based on the preceding checkbox category. so, if i did something like that, is it wrong?
    thank's for your attention

  4. #4
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    What method are you using to send your information from the form. Are you using POST or GET?

    Do :
    Code:
    <pre>
    <?print_r($_GET);?>
    </pre>
    It should output a list of all your PHP _GET variables. Also bear in mind that you have spaces in the name of the form inputs. e.g. "medicalName price" and if you are stripping out all whitespace then you're looking for "medicalNameprice" which obviously doesn't exist.

    Use the above code and see what it gives you. I suspect you are looking for the wrong _GET variables

  5. #5
    Join Date
    Feb 2007
    Posts
    26
    Hi,

    thank's a lot for your reply..
    the print_r($_GET) is really help me a lot..
    it gives me the value of 'general_check-up_price', even though if i use echo, it returns 'general check-up price', so i use str_replace to replace the spaces into "_"

    thank's a lot =)

Posting Permissions

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