Loading ...
Sorry, an error occurred while loading the content.

Re: How to create a select from a mysql db

Expand Messages
  • albertp3
    ... An example of building the associative array from the database would be very helpful. Thanks.
    Message 1 of 6 , Jul 10, 2006
    • 0 Attachment
      --- In forms-dev@yahoogroups.com, Manuel Lemos <mlemos@...> wrote:
      >
      > Hello,
      >
      > on 03/24/2006 06:57 AM docu_valencia said the following:
      > > Hello Manuel and members. It's my first post, I have a simple
      > > question. How can I create a select where the options are called from
      > > a mysql database?
      > > I tried to generate an array with the fields but I experienced a lot
      > > of problems.
      >
      > If that is a simple select, there should be no problem. Just create an
      > associative array with the values and options from the database and
      > assign that array to the OPTIONS parameter. The VALUE parameter must be
      > set to one of the values in the OPTIONS array.
      >
      > --

      An example of building the associative array from the database would be very helpful.

      Thanks.
    • aterrade
      Oracle example // Id Organitzador // Omplo les opcions de la select des de la base de dades $select = select id_organitzador,nom from ge_organitzadors order
      Message 2 of 6 , Jul 11, 2006
      • 0 Attachment
        Oracle example


        // Id Organitzador
        // Omplo les opcions de la select des de la base de dades

        $select = "select id_organitzador,nom from ge_organitzadors
        order by id_organitzador asc" ;

        if (Query($conexio,$resultat,$select))
        {
        if ($resultat["NumRows"] > 0)
        {
        for ($i=0; $i<$resultat["NumRows"]; $i++)
        {
        if (isset($valors3))
        {
        // opciĆ³ -
        valor etiqueta
        $valors3[$resultat["Result"]
        ["ID_ORGANITZADOR"][$i]] = $resultat["Result"]["NOM"][$i];
        }
        else
        {
        $valors3= array($resultat["Result"]
        ["ID_ORGANITZADOR"][$i]=>$resultat["Result"]["NOM"][$i]);
        }
        }
        }
        }


        $subscription->AddInput(array(
        "TYPE"=>"select",
        "NAME"=>"e_id_organitzador",
        "ID"=>"e_id_organitzador",
        "VALUE"=>$resultat["Result"]["ID_ORGANITZADOR"][0],
        "SIZE"=>1,
        "OPTIONS"=>$valors3,
        "LABEL"=>"<u>O</u>rganitzador",
        "ACCESSKEY"=>"O"
        ));


        This show a select box with the persons who organize activities but
        when you selected it the form post a numeric value that is his
        identifier.

        Show Real values
        Albert 123
        Miquel 43
        Joan 223

        --- In forms-dev@yahoogroups.com, "albertp3" <apadley@...> wrote:
        >
        > --- In forms-dev@yahoogroups.com, Manuel Lemos <mlemos@> wrote:
        > >
        > > Hello,
        > >
        > > on 03/24/2006 06:57 AM docu_valencia said the following:
        > > > Hello Manuel and members. It's my first post, I have a simple
        > > > question. How can I create a select where the options are
        called from
        > > > a mysql database?
        > > > I tried to generate an array with the fields but I experienced
        a lot
        > > > of problems.
        > >
        > > If that is a simple select, there should be no problem. Just
        create an
        > > associative array with the values and options from the database
        and
        > > assign that array to the OPTIONS parameter. The VALUE parameter
        must be
        > > set to one of the values in the OPTIONS array.
        > >
        > > --
        >
        > An example of building the associative array from the database
        would be very helpful.
        >
        > Thanks.
        >
      • albertp3
        ... Thanks. That pushed me in the right direction and I got it working in MySQL.
        Message 3 of 6 , Jul 11, 2006
        • 0 Attachment
          --- In forms-dev@yahoogroups.com, "aterrade" <aterradellas@...> wrote:
          >
          > Oracle example
          >
          >
          > // Id Organitzador
          > // Omplo les opcions de la select des de la base de dades
          >
          > $select = "select id_organitzador,nom from ge_organitzadors
          > order by id_organitzador asc" ;
          >
          > if (Query($conexio,$resultat,$select))
          > {
          > if ($resultat["NumRows"] > 0)
          > {
          > for ($i=0; $i<$resultat["NumRows"]; $i++)
          > {
          > if (isset($valors3))
          > {
          > // opciĆ³ -
          > valor etiqueta
          > $valors3[$resultat["Result"]
          > ["ID_ORGANITZADOR"][$i]] = $resultat["Result"]["NOM"][$i];
          > }
          > else
          > {
          > $valors3= array($resultat["Result"]
          > ["ID_ORGANITZADOR"][$i]=>$resultat["Result"]["NOM"][$i]);
          > }
          > }
          > }
          > }
          >
          >
          > $subscription->AddInput(array(
          > "TYPE"=>"select",
          > "NAME"=>"e_id_organitzador",
          > "ID"=>"e_id_organitzador",
          > "VALUE"=>$resultat["Result"]["ID_ORGANITZADOR"][0],
          > "SIZE"=>1,
          > "OPTIONS"=>$valors3,
          > "LABEL"=>"<u>O</u>rganitzador",
          > "ACCESSKEY"=>"O"
          > ));
          >
          >
          > This show a select box with the persons who organize activities but
          > when you selected it the form post a numeric value that is his
          > identifier.
          >
          > Show Real values
          > Albert 123
          > Miquel 43
          > Joan 223
          >


          Thanks. That pushed me in the right direction and I got it working in MySQL.
        Your message has been successfully submitted and would be delivered to recipients shortly.