req: simple traditional lookup table entry

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • larry@portcommodore.com

    req: simple traditional lookup table entry

    Ok I am re-coding our apps in PHP and am looking for ways to make parts
    easily updateable, One of the challenges in my field (non-rpofit) are
    various lookup tables (for incomes etc).

    An example table would be something like a rate lookup, where you
    travel down the family size column and when you reach the right income
    you look for the rate. An example here:

    RATE - FAM2 -FAM3 - FAM4 - FAM5
    100 - 1200 - 1300 - 1375 - 1380
    123 - 1220 - 1320 - 1387 - 1392
    143 - 1242 - 1342 - 1400 - 1412

    So if it were a family of 3 with 1322 the rate would be 123.

    To make this into a DB for lookup is a cinch, but for someone to
    enter/update this compact table into a lookup DB is a pain.

    Is there any libraries out there already to read a text file like the
    above (more likely CSV) or a similarly formatted spreadsheet, or one
    that presents a table entry method to expidite the entry of a table
    like this?

    Larry

  • Geoff Berrow

    #2
    Re: req: simple traditional lookup table entry

    Message-ID: <1166568140.013 219.144440@f1g2 000cwa.googlegr oups.comfrom
    larry@portcommo dore.com contained the following:
    >RATE - FAM2 -FAM3 - FAM4 - FAM5
    >100 - 1200 - 1300 - 1375 - 1380
    >123 - 1220 - 1320 - 1387 - 1392
    >143 - 1242 - 1342 - 1400 - 1412
    >
    >So if it were a family of 3 with 1322 the rate would be 123.
    >
    >To make this into a DB for lookup is a cinch, but for someone to
    >enter/update this compact table into a lookup DB is a pain.
    >
    >Is there any libraries out there already to read a text file like the
    >above (more likely CSV) or a similarly formatted spreadsheet, or one
    >that presents a table entry method to expidite the entry of a table
    >like this?
    You can do it with a simple loop. Let's say the data was in a file
    called data.txt like so:

    100,1200,1300,1 375,1380
    123,1220,1320,1 387,1392
    143,1242,1342,1 400,1412

    Then you just need something like:
    <?php
    //db connect goes here
    $data=file('dat a.txt');
    foreach ($data as $value){
    $line=str_repla ce(",","','",$v alue);
    $sql="INSERT INTO table VALUES('$line') ";
    mysql_query($sq l);
    }
    ?>


    --
    Geoff Berrow (put thecat out to email)
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/

    Comment

    • Jerry Stuckle

      #3
      Re: req: simple traditional lookup table entry

      larry@portcommo dore.com wrote:
      Ok I am re-coding our apps in PHP and am looking for ways to make parts
      easily updateable, One of the challenges in my field (non-rpofit) are
      various lookup tables (for incomes etc).
      >
      An example table would be something like a rate lookup, where you
      travel down the family size column and when you reach the right income
      you look for the rate. An example here:
      >
      RATE - FAM2 -FAM3 - FAM4 - FAM5
      100 - 1200 - 1300 - 1375 - 1380
      123 - 1220 - 1320 - 1387 - 1392
      143 - 1242 - 1342 - 1400 - 1412
      >
      So if it were a family of 3 with 1322 the rate would be 123.
      >
      To make this into a DB for lookup is a cinch, but for someone to
      enter/update this compact table into a lookup DB is a pain.
      >
      Is there any libraries out there already to read a text file like the
      above (more likely CSV) or a similarly formatted spreadsheet, or one
      that presents a table entry method to expidite the entry of a table
      like this?
      >
      Larry
      >
      Larry,

      Check out fgetcsv(). It does wonders with csv files.

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • larry@portcommodore.com

        #4
        Re: req: simple traditional lookup table entry



        On Dec 19, 4:56 pm, Geoff Berrow <blthe...@ckdog .co.ukwrote:
        Message-ID: <1166568140.013 219.144440@f1g2 000cwa.googlegr oups.comfrom
        You can do it with a simple loop. Let's say the data was in a file
        called data.txt like so:
        >
        100,1200,1300,1 375,1380
        123,1220,1320,1 387,1392
        143,1242,1342,1 400,1412
        ...
        Ok, so there is no real tool for inputting/processing lookup tables.
        Thanks for the tips, Ill get on to working out something.

        Larry

        Comment

        Working...