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

how save elements of an array in database

Expand Messages
  • melissa_brown35
    how save elements of an array in database when we do not know that how many elements are in array Like elements might be 5 or 10.
    Message 1 of 11 , Nov 2, 2010
    • 0 Attachment
      how save elements of an array in database when we do not know that how many elements are in array Like elements might be 5 or 10.
    • Patrick Price
      As long as there isn t a massive amount of data to save you can just use serialize() and unserialize() to save the data to a text field in the database. ...
      Message 2 of 11 , Nov 3, 2010
      • 0 Attachment
        As long as there isn't a massive amount of data to save you can just use
        serialize() and unserialize() to save the data to a text field in the
        database.
        On Nov 3, 2010 7:10 PM, "melissa_brown35" <melissa_brown35@...> wrote:
        > how save elements of an array in database when we do not know that how
        many elements are in array Like elements might be 5 or 10.
        >


        [Non-text portions of this message have been removed]
      • José Miguel Santibáñez A.
        ... serialize... -- José Miguel Santibáñez jms@nivel5.cl
        Message 3 of 11 , Nov 3, 2010
        • 0 Attachment
          > how save elements of an array in database when we do not know that how
          > many elements are in array Like elements might be 5 or 10.
          >

          serialize...


          --
          José Miguel Santibáñez
          jms@...
        • kyomuhendo babra
          Loop through the array using foreach loop ________________________________ From: José Miguel Santibáñez A. To: php-objects@yahoogroups.com
          Message 4 of 11 , Nov 3, 2010
          • 0 Attachment
            Loop through the array using foreach loop




            ________________________________
            From: José Miguel Santibáñez A. <jms@...>
            To: php-objects@yahoogroups.com
            Sent: Thu, November 4, 2010 2:32:06 AM
            Subject: Re: [php-objects] how save elements of an array in database



            > how save elements of an array in database when we do not know that how
            > many elements are in array Like elements might be 5 or 10.
            >

            serialize...

            --
            José Miguel Santibáñez
            jms@...






            [Non-text portions of this message have been removed]
          • anas. muhammed
            You can get no of elements in array using count($array) 2010/11/4 José Miguel Santibáñez A. ... -- Regards -!m@- anas@engineersnetwork.org
            Message 5 of 11 , Nov 3, 2010
            • 0 Attachment
              You can get no of elements in array using count($array)


              2010/11/4 Jos� Miguel Santib��ez A. <jms@...>

              >
              >
              >
              > > how save elements of an array in database when we do not know that how
              > > many elements are in array Like elements might be 5 or 10.
              > >
              >
              > serialize...
              >
              > --
              > Jos� Miguel Santib��ez
              > jms@... <jms%40nivel5.cl>
              >
              >
              >



              --
              Regards
              -!m@-
              anas@...
              anas.muhammed@...
              itsmeima@...
              itsmeima@...
              imanas@...
              +919496371048
              -ima-
              *--------------------------------------------------------------*
              *Think before you print...........
              Save trees, Save Vegetation, Save Humanity..*
              � *Please do not print this e-mail unless it is absolutely necessary. SAVE
              PAPER. Protect the Environment.* P


              [Non-text portions of this message have been removed]
            • Joseph Griffin
              you may use simple foreach loop for that.
              Message 6 of 11 , Nov 4, 2010
              • 0 Attachment
                you may use simple "foreach" loop for that.

                <?php
                $arr = array("one", "two", "three");

                foreach ($arr as $value) {
                $insertDbSql = "INSERT INFO `myTbl` VALUES('$value')";
                }
                ?>



                ________________________________
                From: melissa_brown35 <melissa_brown35@...>
                To: php-objects@yahoogroups.com
                Sent: Tue, November 2, 2010 2:52:03 PM
                Subject: [php-objects] how save elements of an array in database


                how save elements of an array in database when we do not know that how many
                elements are in array Like elements might be 5 or 10.




                [Non-text portions of this message have been removed]
              • Prasad C
                If that s single dimensional array, implode it to string and store in DB as VARCHAR or MEDIUMTEXT or TEXT. Use explode when you want it back to array.. ... --
                Message 7 of 11 , Nov 4, 2010
                • 0 Attachment
                  If that's single dimensional array, implode it to string and store in DB as
                  VARCHAR or MEDIUMTEXT or TEXT.
                  Use explode when you want it back to array..

                  On Thu, Nov 4, 2010 at 1:37 PM, Joseph Griffin <griffinhere@...>wrote:

                  >
                  >
                  > you may use simple "foreach" loop for that.
                  >
                  > <?php
                  > $arr = array("one", "two", "three");
                  >
                  > foreach ($arr as $value) {
                  > $insertDbSql = "INSERT INFO `myTbl` VALUES('$value')";
                  > }
                  > ?>
                  >
                  > ________________________________
                  > From: melissa_brown35 <melissa_brown35@...<melissa_brown35%40yahoo.com>
                  > >
                  > To: php-objects@yahoogroups.com <php-objects%40yahoogroups.com>
                  > Sent: Tue, November 2, 2010 2:52:03 PM
                  > Subject: [php-objects] how save elements of an array in database
                  >
                  >
                  > how save elements of an array in database when we do not know that how many
                  >
                  > elements are in array Like elements might be 5 or 10.
                  >
                  > [Non-text portions of this message have been removed]
                  >
                  >
                  >



                  --
                  -Prasad C
                  +91 994 672 5488
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  Please don't print this e-mail unless absolutely necessary, lets save some
                  trees, and Mother Nature


                  [Non-text portions of this message have been removed]
                • bodipalli
                  Sorry this is not good idea. You have to use the extended insert logic. example INSERT INTO `ascdes` (`id`, `name`, `sno`, `yn`) VALUES (1, prabhakar , 1225,
                  Message 8 of 11 , Nov 4, 2010
                  • 0 Attachment
                    Sorry this is not good idea.
                    You have to use the extended insert logic.
                    example

                    INSERT INTO `ascdes` (`id`, `name`, `sno`, `yn`) VALUES
                    (1, 'prabhakar', 1225, '1'),
                    (2, 'ram', 1226, '0'),
                    (3, 'venkat', 1227, '1'),
                    (4, 'santhosh', 1228, '0'),
                    (5, 'arijit', 1229, '1'),
                    (6, 'satyam', 1230, '1'),
                    (7, 'swetha', 1231, '0'),
                    (8, 'sasi', 1232, '1'),
                    (9, 'dugraprasad', 1233, '0');

                    this you can frame the logic as

                    <?php
                    $arr = array("one", "two", "three");
                    $insertDbSql = "INSERT INFO `myTbl`(arr_val) VALUES ";
                    $comma = "";
                    foreach ($arr as $value) {
                    $insertDbSql .= $comma."('".$value."')";
                    }
                    mysql_query($insertDbSql);
                    ?>

                    this is correct logic

                    --- In php-objects@yahoogroups.com, Prasad C <prasadcnair@...> wrote:
                    >
                    > If that's single dimensional array, implode it to string and store in DB as
                    > VARCHAR or MEDIUMTEXT or TEXT.
                    > Use explode when you want it back to array..
                    >
                    > On Thu, Nov 4, 2010 at 1:37 PM, Joseph Griffin <griffinhere@...>wrote:
                    >
                    > >
                    > >
                    > > you may use simple "foreach" loop for that.
                    > >
                    > > <?php
                    > > $arr = array("one", "two", "three");
                    > >
                    > > foreach ($arr as $value) {
                    > > $insertDbSql = "INSERT INFO `myTbl` VALUES('$value')";
                    > > }
                    > > ?>
                    > >
                    > > ________________________________
                    > > From: melissa_brown35 <melissa_brown35@...<melissa_brown35%40yahoo.com>
                    > > >
                    > > To: php-objects@yahoogroups.com <php-objects%40yahoogroups.com>
                    > > Sent: Tue, November 2, 2010 2:52:03 PM
                    > > Subject: [php-objects] how save elements of an array in database
                    > >
                    > >
                    > > how save elements of an array in database when we do not know that how many
                    > >
                    > > elements are in array Like elements might be 5 or 10.
                    > >
                    > > [Non-text portions of this message have been removed]
                    > >
                    > >
                    > >
                    >
                    >
                    >
                    > --
                    > -Prasad C
                    > +91 994 672 5488
                    > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    > Please don't print this e-mail unless absolutely necessary, lets save some
                    > trees, and Mother Nature
                    >
                    >
                    > [Non-text portions of this message have been removed]
                    >
                  • Kenny Tean
                    Use json instead.. U can store multi-dimentional array and can be used in multi-platform.. Sent from my iPhone On 04-Nov-2010, at 6:06 PM, Prasad C
                    Message 9 of 11 , Nov 4, 2010
                    • 0 Attachment
                      Use json instead.. U can store multi-dimentional array and can be used in multi-platform..

                      Sent from my iPhone

                      On 04-Nov-2010, at 6:06 PM, Prasad C <prasadcnair@...> wrote:

                      If that's single dimensional array, implode it to string and store in DB as
                      VARCHAR or MEDIUMTEXT or TEXT.
                      Use explode when you want it back to array..

                      On Thu, Nov 4, 2010 at 1:37 PM, Joseph Griffin <griffinhere@...>wrote:



                      you may use simple "foreach" loop for that.

                      <?php
                      $arr = array("one", "two", "three");

                      foreach ($arr as $value) {
                      $insertDbSql = "INSERT INFO `myTbl` VALUES('$value')";
                      }
                      ?>

                      ________________________________
                      From: melissa_brown35 <melissa_brown35@...<melissa_brown35%40yahoo.com>

                      To: php-objects@yahoogroups.com <php-objects%40yahoogroups.com>
                      Sent: Tue, November 2, 2010 2:52:03 PM
                      Subject: [php-objects] how save elements of an array in database


                      how save elements of an array in database when we do not know that how many

                      elements are in array Like elements might be 5 or 10.

                      [Non-text portions of this message have been removed]






                      --
                      -Prasad C
                      +91 994 672 5488
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                      Please don't print this e-mail unless absolutely necessary, lets save some
                      trees, and Mother Nature


                      [Non-text portions of this message have been removed]



                      ------------------------------------

                      Are you looking for a PHP job?
                      Join the PHP Professionals directory Now!
                      http://www.phpclasses.org/jobs/
                      Yahoo! Groups Links
                    • bodipalli prabhkarrao
                      Hey Kenny Tean you sent excellent idea. No more at all ________________________________ From: Kenny Tean To:
                      Message 10 of 11 , Nov 4, 2010
                      • 0 Attachment
                        Hey Kenny Tean
                        you sent excellent idea. No more at all




                        ________________________________
                        From: Kenny Tean <kennytean@...>
                        To: "php-objects@yahoogroups.com" <php-objects@yahoogroups.com>
                        Cc: "php-objects@yahoogroups.com" <php-objects@yahoogroups.com>
                        Sent: Thu, 4 November, 2010 4:41:42 PM
                        Subject: Re: [php-objects] how save elements of an array in database


                        Use json instead.. U can store multi-dimentional array and can be used in
                        multi-platform..

                        Sent from my iPhone

                        On 04-Nov-2010, at 6:06 PM, Prasad C <prasadcnair@...> wrote:

                        If that's single dimensional array, implode it to string and store in DB as
                        VARCHAR or MEDIUMTEXT or TEXT.
                        Use explode when you want it back to array..

                        On Thu, Nov 4, 2010 at 1:37 PM, Joseph Griffin <griffinhere@...>wrote:

                        you may use simple "foreach" loop for that.

                        <?php
                        $arr = array("one", "two", "three");

                        foreach ($arr as $value) {
                        $insertDbSql = "INSERT INFO `myTbl` VALUES('$value')";
                        }
                        ?>

                        ________________________________
                        From: melissa_brown35 <melissa_brown35@...<melissa_brown35%40yahoo.com>

                        To: php-objects@yahoogroups.com <php-objects%40yahoogroups.com>
                        Sent: Tue, November 2, 2010 2:52:03 PM
                        Subject: [php-objects] how save elements of an array in database

                        how save elements of an array in database when we do not know that how many

                        elements are in array Like elements might be 5 or 10.

                        [Non-text portions of this message have been removed]

                        --
                        -Prasad C
                        +91 994 672 5488
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                        Please don't print this e-mail unless absolutely necessary, lets save some
                        trees, and Mother Nature

                        [Non-text portions of this message have been removed]

                        ------------------------------------

                        Are you looking for a PHP job?
                        Join the PHP Professionals directory Now!
                        http://www.phpclasses.org/jobs/
                        Yahoo! Groups Links






                        [Non-text portions of this message have been removed]
                      • Joe Forsythe
                        Depending on what you are trying to accomplish: 1. count() will give you the number of elements in the array. 2. serialize() will give you a storable value 3.
                        Message 11 of 11 , Nov 4, 2010
                        • 0 Attachment
                          Depending on what you are trying to accomplish:
                          1. count() will give you the number of elements in the array.
                          2. serialize() will give you a storable value
                          3. If you need a 1:1 relationship with the database, you will need to plan
                          the database accordingly.
                          --
                          Joe

                          On Tue, Nov 2, 2010 at 6:52 AM, melissa_brown35
                          <melissa_brown35@...>wrote:

                          >
                          >
                          > how save elements of an array in database when we do not know that how many
                          > elements are in array Like elements might be 5 or 10.
                          >


                          [Non-text portions of this message have been removed]
                        Your message has been successfully submitted and would be delivered to recipients shortly.