Get array from string

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

    Get array from string

    Hi,

    I would like to store data from a string in a database after some
    stripping. So for example:

    <li><a href="xxx">yyy</a> - zzz
    <li><a href="aaa">bbb</a> - ccc

    In this example (which is one string) I would like to store the
    variable data in a MySQL table. In order to do that I need to first
    get the variable data from the string, which I can manage I think.

    But how do I get the data into the database? Do I need to insert the
    data into one or more arrays? And how can I then insert it into the
    table?

    Kind regards,

    Martijn
  • Erwin Moller

    #2
    Re: Get array from string

    Martijn Hertog wrote:
    [color=blue]
    > Hi,
    >
    > I would like to store data from a string in a database after some
    > stripping. So for example:
    >
    > <li><a href="xxx">yyy</a> - zzz
    > <li><a href="aaa">bbb</a> - ccc
    >
    > In this example (which is one string) I would like to store the
    > variable data in a MySQL table. In order to do that I need to first
    > get the variable data from the string, which I can manage I think.
    >
    > But how do I get the data into the database? Do I need to insert the
    > data into one or more arrays? And how can I then insert it into the
    > table?
    >
    > Kind regards,
    >
    > Martijn[/color]

    Hi Martijn,

    I suggest you create a table with:
    1) unique id (PK)
    2) hrefvalue (text)
    3) hlinktext (text)
    4) extracomment (text)

    and store a record at a time in it.
    I don't see any advantage in storing arrays of strings in a database. (If
    possible with MySQL, which I am not sure of because I only use Postgresql)

    Regards,
    Erwin Moller

    Comment

    • Martijn Hertog

      #3
      Re: Get array from string

      Erwin Moller <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> wrote in message news:<404589ae$ 0$573$e4fe514c@ news.xs4all.nl> ...[color=blue]
      > Martijn Hertog wrote:
      >[color=green]
      > > Hi,
      > >
      > > I would like to store data from a string in a database after some
      > > stripping. So for example:
      > >
      > > <li><a href="xxx">yyy</a> - zzz
      > > <li><a href="aaa">bbb</a> - ccc
      > >
      > > In this example (which is one string) I would like to store the
      > > variable data in a MySQL table. In order to do that I need to first
      > > get the variable data from the string, which I can manage I think.
      > >
      > > But how do I get the data into the database? Do I need to insert the
      > > data into one or more arrays? And how can I then insert it into the
      > > table?
      > >
      > > Kind regards,
      > >
      > > Martijn[/color]
      >
      > Hi Martijn,
      >
      > I suggest you create a table with:
      > 1) unique id (PK)
      > 2) hrefvalue (text)
      > 3) hlinktext (text)
      > 4) extracomment (text)
      >
      > and store a record at a time in it.
      > I don't see any advantage in storing arrays of strings in a database. (If
      > possible with MySQL, which I am not sure of because I only use Postgresql)
      >
      > Regards,
      > Erwin Moller[/color]

      Thank you Erwin,

      Which code can I use to get the data into the database table?

      Kind regards,

      Martijn

      Comment

      • Matthias Esken

        #4
        Re: Get array from string

        hertogm@yahoo.c om (Martijn Hertog) schrieb:
        [color=blue]
        > Which code can I use to get the data into the database table?[/color]

        mysql_query()

        Hava look at the documentation, starting at
        http://www.php.net/manual/en/ref.mysql.php.

        Regards,
        Matthias

        Comment

        • Martin

          #5
          Re: Get array from string

          Okay, that seems to be a function that should be used of course. Could you
          please send me an example code for the whole procedure, since I am not quite
          sure how to get the variables ready for usage in an MySQL insert function.

          Kind regards,

          Martijn

          "Matthias Esken" <muelleimer2004 nospam@usenetve rwaltung.org> wrote in
          message news:c255sr.134 .1@usenet.esken .de...[color=blue]
          > hertogm@yahoo.c om (Martijn Hertog) schrieb:
          >[color=green]
          > > Which code can I use to get the data into the database table?[/color]
          >
          > mysql_query()
          >
          > Hava look at the documentation, starting at
          > http://www.php.net/manual/en/ref.mysql.php.
          >
          > Regards,
          > Matthias[/color]


          Comment

          • Martin

            #6
            Re: Get array from string

            For example, I have the string:

            #li##a href=http://www.cia.gov/cia/#CIA Factbook#/a# - Overview of Korea's
            people, geography etc #li##a href=http://encarta.msn.com #Encarta#/a# -
            Korean geography, society, culture, economy, government, and history.
            ----------
            I would like the data in this string stored in a MySQL table, like this:
            id url name
            description
            ------------------------------------------------------------------------
            1 http://www.cia.gov/cia/ CIA Factbook Overview ....
            2 http://encarta.msn.com Encarta Korean ...

            Kind regards,

            Martijn


            "Martin" <hertogm@tiscal i.nl> wrote in message
            news:4046351c$0 $41753$5fc3050@ dreader2.news.t iscali.nl...[color=blue]
            > Okay, that seems to be a function that should be used of course. Could you
            > please send me an example code for the whole procedure, since I am not[/color]
            quite[color=blue]
            > sure how to get the variables ready for usage in an MySQL insert function.
            >
            > Kind regards,
            >
            > Martijn
            >
            > "Matthias Esken" <muelleimer2004 nospam@usenetve rwaltung.org> wrote in
            > message news:c255sr.134 .1@usenet.esken .de...[color=green]
            > > hertogm@yahoo.c om (Martijn Hertog) schrieb:
            > >[color=darkred]
            > > > Which code can I use to get the data into the database table?[/color]
            > >
            > > mysql_query()
            > >
            > > Hava look at the documentation, starting at
            > > http://www.php.net/manual/en/ref.mysql.php.
            > >
            > > Regards,
            > > Matthias[/color]
            >
            >[/color]


            Comment

            Working...