Help Please

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jsd219

    Help Please

    I am going crazy over here. here is my code:

    $query = "SELECT SEC_TITLE, SEC_ID
    FROM section
    WHERE SEC_TITLE != ''";

    $result = mysql_query($qu ery);

    echo "<form action='#'>\r\n <select name='id'>";
    while ($line = mysql_fetch_arr ay($result, MYSQL_NUM)) {
    $section = $line[0];
    $id = $line[1];

    //echo " <option value=$section> $section\r\n";

    echo " <option value='$id'>$se ction</option>\n";

    }

    I need to pull both a name=id & name=section. and then send both via
    the option value. What this does is it pulls all the section titles
    for the table section and places them into a drop down box, when you
    select one of the sections and send the form it places that section
    title in the section field of the category table. i need it to not
    only send the section title but also the section id to the id field of
    the category table.

    I am at a complete loss, Please someone help me

    God bless
    jason

  • =?ISO-8859-15?Q?Iv=E1n_S=E1nchez_Ortega?=

    #2
    Re: Help Please

    jsd219 wrote:
    I need to pull both a name=id & name=section. and then send both via
    the option value.
    Why do you *need* to do that?

    --
    ----------------------------------
    Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

    "Sometimes when reading Goethe I have the paralyzing suspicion that he is
    trying to be funny."
    - Guy Davenport

    Comment

    • Jon Slaughter

      #3
      Re: Help Please


      "jsd219" <info@musiclane recording.comwr ote in message
      news:1181863278 .221161.148450@ q19g2000prn.goo glegroups.com.. .
      >I am going crazy over here. here is my code:
      >
      $query = "SELECT SEC_TITLE, SEC_ID
      FROM section
      WHERE SEC_TITLE != ''";
      >
      $result = mysql_query($qu ery);
      >
      echo "<form action='#'>\r\n <select name='id'>";
      while ($line = mysql_fetch_arr ay($result, MYSQL_NUM)) {
      $section = $line[0];
      $id = $line[1];
      >
      //echo " <option value=$section> $section\r\n";
      >
      echo " <option value='$id'>$se ction</option>\n";
      >
      }
      >
      I need to pull both a name=id & name=section. and then send both via
      the option value. What this does is it pulls all the section titles
      for the table section and places them into a drop down box, when you
      select one of the sections and send the form it places that section
      title in the section field of the category table. i need it to not
      only send the section title but also the section id to the id field of
      the category table.
      >
      I am at a complete loss, Please someone help me
      >
      I can't make out what your talking about but maybe passing id and section in
      the option value might work?

      i.e., use something like $id.$seperator. $section? and then parse when you
      get it

      Jon


      Comment

      • shimmyshack

        #4
        Re: Help Please

        On Jun 15, 12:21 am, jsd219 <i...@musiclane recording.comwr ote:
        I am going crazy over here. here is my code:
        >
        $query = "SELECT SEC_TITLE, SEC_ID
        FROM section
        WHERE SEC_TITLE != ''";
        >
        $result = mysql_query($qu ery);
        >
        echo "<form action='#'>\r\n <select name='id'>";
        while ($line = mysql_fetch_arr ay($result, MYSQL_NUM)) {
        $section = $line[0];
        $id = $line[1];
        >
        //echo " <option value=$section> $section\r\n";
        >
        echo " <option value='$id'>$se ction</option>\n";
        >
        }
        >
        I need to pull both a name=id & name=section. and then send both via
        the option value. What this does is it pulls all the section titles
        for the table section and places them into a drop down box, when you
        select one of the sections and send the form it places that section
        title in the section field of the category table. i need it to not
        only send the section title but also the section id to the id field of
        the category table.
        >
        I am at a complete loss, Please someone help me
        >
        God bless
        jason

        just combine both id and section into a single variable!

        echo '<form method="get">';
        echo '<select name="combined" >';
        echo ' <option value="'.$id.'| '.$section.'">$ section</option>'."\n";
        #etc...
        echo '</select>';
        echo '</form>';


        <?php

        if( isset($_GET['combined'] && ($_GET['combined']!='') )
        {
        $arrayIdAndSect ion = explode( '|', $_GET['combined'] );
        $id = $arrayIdAndSect ion[0];
        $section = $arrayIdAndSect ion[1];
        }

        ?>



        Comment

        • Michael Fesser

          #5
          Re: Help Please

          ..oO(jsd219)
          >[...]
          echo " <option value='$id'>$se ction</option>\n";
          >
          >I need to pull both a name=id & name=section. and then send both via
          >the option value.
          I'm wondering why you want that. The above is the common way of doing
          such things and all you really need.
          >What this does is it pulls all the section titles
          >for the table section and places them into a drop down box, when you
          >select one of the sections and send the form it places that section
          >title in the section field of the category table.
          The section title is just for displaying, all you need for the internal
          handling and processing is the section ID.
          >i need it to not
          >only send the section title but also the section id to the id field of
          >the category table.
          I'm not sure I can follow you. What do you want to do with that after
          the form submission?

          Micha

          Comment

          Working...