how do i get the id to store in my table instead of the name field displayed in DDL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • princelindie
    New Member
    • Feb 2008
    • 28

    how do i get the id to store in my table instead of the name field displayed in DDL

    I am using code that looks something like this:
    [php]
    <?php
    mysql_connect(" localhost", "xxxx_xx", "xxx") or die(mysql_error ());
    mysql_select_db ("xxxx_xxx") or die(mysql_error ());
    $query="SELECT Bloom_Name FROM ihs";
    $result = mysql_query($qu ery);

    echo '<select name="ihs" onchange="this. form.submit()"> ';
    while($nt=mysql _fetch_array($r esult)){ //Array or records stored in $nt
    echo '<option value="' . $nt['id'] . '">' . $nt['Bloom_Name'] . '</option>';
    /* Option values are added by looping through the array */
    }
    echo '</select>'; // Closing of list box
    ?>
    [/php]how do i get the id to store in my table instead of the name field displayed in Drop Down List
    Last edited by ronverdonk; Mar 11 '08, 01:38 PM. Reason: code tags
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    You know that we expect your code to be posted in [CODE] tags (See How to Ask a Question).

    This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

    Please use the tags in future.

    MODERATOR.

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      After submit, the $_POST array contains all selected values under key 'ihs'. To check this, print the $_POST array in the second phase where you process your submitted form[php]print_r($_POST) ;[/php]
      Ronald

      Comment

      • princelindie
        New Member
        • Feb 2008
        • 28

        #4
        [php]print_r($_POST) ;[/php] this help.
        was able to see where the error was..

        thanks

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          Originally posted by princelindie
          [php]print_r($_POST) ;[/php] this help.
          was able to see where the error was..

          thanks
          You're welcome. See you next time.

          Ronald

          Comment

          Working...