PHP beginner question

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default PHP beginner question

    Hello,

    I am currently learning PHP, and I have a problem with some variables.
    On the first page (choix.php), there is a form that lists product
    categories.This is the concerned part:

    echo "<form action='dc.php' method='post'>
    <select name='p_type2' value='p_type2'> \n";

    while ($ligne = mysql_fetch_array($result))
    { extract($ligne);
    echo "<option value='$p_type2'>$p_type\n";
    }
    echo "</select>\n";

    echo "<input type='submit'".
    "value=\"Choisissez un type de produit\"></form>\n";?>

    On the other page, dc.php , the program has to list the products in
    the category chosen by the user above. I want the product chosen to be
    inserted in

    $typeproduit = "$HTTP_POST_VARS[$p_type2]";

    where $type_produit is the product chosen. (When i write, for
    example,:

    $type_produit = "CPU";

    the program works. But it doesn't work when I put a variable. Can you
    help me ?

    Thank you


    Ben C.
    Ben Guest

  2. Similar Questions and Discussions

    1. Beginner question
      new to the world of asp! I'm trying to define session variables using the following code: Session("Employee")= when i replace the Session...
    2. FMS Beginner Question
      I'm a total newbie here so I appreciate any help. We just installed FMS and would like to use it for streaming videos. I've researched and found...
    3. Simple Question From Beginner
      I have created an swf movie, which I embedded to my site. I want my movie to play only once , just when the mouse cursor hovers over this movie...
    4. beginner for a small question
      Hello, The pictures of my animation is beautiful in flash mx and when i test animation the pictures are not very nice - lost quality... how to...
    5. A Beginner question -where to start?
      On Sat, 28 Jun 2003 09:19:52 +0100, redjupiter wrote: System descriptions can be found here: http://sunsolve.sun.com/handbook_pub/Systems/
  3. #2

    Default Re: PHP beginner question

    Ben wrote:

    [snip]
    > $typeproduit = "$HTTP_POST_VARS[$p_type2]";
    Try:
    $typeproduit = $HTTP_POST_VARS[$p_type2];

    --
    MeerKat

    MeerKat Guest

  4. #3

    Default Re: PHP beginner question

    On 23 Sep 2003 13:40:14 -0700, [email]microben@hotmail.com[/email] (Ben) wrote:
    > <select name='p_type2' value='p_type2'> \n";
    The select element does not have a value attribute.
    >while ($ligne = mysql_fetch_array($result))
    >{ extract($ligne);
    > echo "<option value='$p_type2'>$p_type\n";
    >}
    >echo "</select>\n";
    >
    >echo "<input type='submit'".
    > "value=\"Choisissez un type de produit\"></form>\n";?>
    >
    >On the other page, dc.php , the program has to list the products in
    >the category chosen by the user above. I want the product chosen to be
    >inserted in
    >
    >$typeproduit = "$HTTP_POST_VARS[$p_type2]";
    $typeproduit = $_POST['p_type2'];

    --
    Andy Hassall (andy@andyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    Space: disk usage analysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    Andy Hassall Guest

  5. #4

    Default Re: PHP beginner question

    Andy Hassall <andy@andyh.co.uk> wrote in message news:<vdl1nv4jloiksmv6con6bjoan7qgdn2q8e@4ax.com>. ..
    > On 23 Sep 2003 13:40:14 -0700, [email]microben@hotmail.com[/email] (Ben) wrote:
    >
    > > <select name='p_type2' value='p_type2'> \n";
    >
    > The select element does not have a value attribute.
    You mean I should remove the value='p_type2'> /n"; ?
    or should I put another value ?

    Thank you for your answers guys.
    Ben Guest

  6. #5

    Default Re: PHP beginner question

    Ben wrote:
    >Andy Hassall <andy@andyh.co.uk> wrote in message news:<vdl1nv4jloiksmv6con6bjoan7qgdn2q8e@4ax.com>. ..
    >> On 23 Sep 2003 13:40:14 -0700, [email]microben@hotmail.com[/email] (Ben) wrote:
    >>
    >> > <select name='p_type2' value='p_type2'> \n";
    >>
    >> The select element does not have a value attribute.
    >
    >You mean I should remove the value='p_type2'> /n"; ?
    >or should I put another value ?
    You should remove the value attribute from the select

    AFAIK the select construct is like this:

    <select name="combo">
    <option value="v1">text1</option>
    <option value="v2">text2</option>
    <!-- ... -->
    <option value="vn">textn</option>
    </select>

    And you check it in php with $_POST['combo'] or $_GET['combo']
    according to the method used for the form.

    The text1, text2, ..., textn are only visible to the browser; you will
    not have access to them in the script the form is submitted to --
    often they are the same as the v1, v2, ..., vn but that is not
    mandatory.


    --
    I have a spam filter working.
    To mail me include "urkxvq" (with or without the quotes)
    in the subject line, or your mail will be ruthlessly discarded.
    Pedro Guest

  7. #6

    Default Re: PHP beginner question

    I noticed that Message-ID: <5he4nvca5f74c03l7hqg3uss7fd4skrd8j@4ax.com>
    from Pedro contained the following:
    ><select name="combo">
    > <option value="v1">text1</option>
    > <option value="v2">text2</option>
    > <!-- ... -->
    > <option value="vn">textn</option>
    ></select>
    >
    >And you check it in php with $_POST['combo'] or $_GET['combo']
    >according to the method used for the form.
    >
    >The text1, text2, ..., textn are only visible to the browser; you will
    >not have access to them in the script the form is submitted to --
    >often they are the same as the v1, v2, ..., vn but that is not
    >mandatory.
    But if you leave out the value="", text1, text2 etc become the values.
    --
    Geoff Berrow
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs [url]http://www.ckdog.co.uk/rfdmaker/[/url]
    Geoff Berrow Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139