Incrementing Number in Repeat Region - Help!

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

    Incrementing Number in Repeat Region - Help!

    Anyone help on this? PHP/MySQL

    I have a repeat region displaying records from orders in a CSV format:

    CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Book,25. 95,???
    CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Poster,1 0.00,???
    CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Video,49 .95,???

    I need to have a column where I can assign each item in the order a
    different number incrementally i.e. 1st item = 1, 2nd = 2 etc.

    The ??? (last column) in the above records is where I will insert this
    incremental number to produce (hopefully):

    CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Book,25. 95,1
    CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Poster,1 0.00,2
    CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Video,49 .95,3

    Can anyone help me figure out how to add this incrementing number inside
    this repeating region? I have a distinct orderID (in this case its 18, 2nd
    column) that I can reference from.

    Thanks! - Tom


  • Michael Austin

    #2
    Re: Incrementing Number in Repeat Region - Help!

    Tom wrote:[color=blue]
    > Anyone help on this? PHP/MySQL
    >
    > I have a repeat region displaying records from orders in a CSV format:
    >
    > CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Book,25. 95,???
    > CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Poster,1 0.00,???
    > CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Video,49 .95,???
    >
    > I need to have a column where I can assign each item in the order a
    > different number incrementally i.e. 1st item = 1, 2nd = 2 etc.
    >
    > The ??? (last column) in the above records is where I will insert this
    > incremental number to produce (hopefully):
    >
    > CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Book,25. 95,1
    > CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Poster,1 0.00,2
    > CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Video,49 .95,3
    >
    > Can anyone help me figure out how to add this incrementing number inside
    > this repeating region? I have a distinct orderID (in this case its 18, 2nd
    > column) that I can reference from.
    >
    > Thanks! - Tom
    >
    >[/color]

    First, You really should consider normalizing your data a bit more to REDUCE the
    repeated data...

    you should have a table with the order innformation.

    ID, USER, DATE, CARRIER, SITE, STATE
    18, CALJOE

    and a data table

    ID, ITEM, AMOUNT, ITEM_NUM
    18, CD, 24.00, 1
    ....

    and insert the ITEM_NUM from the form data.

    or if you just need this for display purposes

    loop through the results of the query and add a counter value. I will leave the
    code as a learning experience.


    --
    Michael Austin.
    Consultant - Available.
    Donations welcomed. Http://www.firstdbasource.com/donations.html
    :)

    Comment

    • Tom

      #3
      Re: Incrementing Number in Repeat Region - Help!

      Thanks for the reply,

      In this case I'm building an order import CSV for Peachtree Acct. from the
      OScommerce store. I can't rewrite the OScommerce tables, so I needed to work
      thru it.

      Actually the solution was too easy:

      $i = 1;
      $i ++:

      Thanks


      "Michael Austin" <maustin@firstd basource.com> wrote in message
      news:ryIWc.4836 $Ig7.4649@newss vr24.news.prodi gy.com...[color=blue]
      > Tom wrote:[color=green]
      > > Anyone help on this? PHP/MySQL
      > >
      > > I have a repeat region displaying records from orders in a CSV format:
      > >
      > > CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Book,25. 95,???
      > > CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Poster,1 0.00,???
      > > CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Video,49 .95,???
      > >
      > > I need to have a column where I can assign each item in the order a
      > > different number incrementally i.e. 1st item = 1, 2nd = 2 etc.
      > >
      > > The ??? (last column) in the above records is where I will insert this
      > > incremental number to produce (hopefully):
      > >
      > > CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Book,25. 95,1
      > > CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Poster,1 0.00,2
      > > CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBS ITE,CA,Video,49 .95,3
      > >
      > > Can anyone help me figure out how to add this incrementing number inside
      > > this repeating region? I have a distinct orderID (in this case its 18,[/color][/color]
      2nd[color=blue][color=green]
      > > column) that I can reference from.
      > >
      > > Thanks! - Tom
      > >
      > >[/color]
      >
      > First, You really should consider normalizing your data a bit more to[/color]
      REDUCE the[color=blue]
      > repeated data...
      >
      > you should have a table with the order innformation.
      >
      > ID, USER, DATE, CARRIER, SITE, STATE
      > 18, CALJOE
      >
      > and a data table
      >
      > ID, ITEM, AMOUNT, ITEM_NUM
      > 18, CD, 24.00, 1
      > ...
      >
      > and insert the ITEM_NUM from the form data.
      >
      > or if you just need this for display purposes
      >
      > loop through the results of the query and add a counter value. I will[/color]
      leave the[color=blue]
      > code as a learning experience.
      >
      >
      > --
      > Michael Austin.
      > Consultant - Available.
      > Donations welcomed. Http://www.firstdbasource.com/donations.html
      > :)[/color]


      Comment

      Working...