Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7035251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:16:56+00:00 2026-05-28T01:16:56+00:00

I am looking for the most simple way to pull out a line of

  • 0

I am looking for the most simple way to pull out a line of data from a flat file database with PHP based on a variable ID number.

For example, if the page is passed the ID of 10001 it grabs the first name, last name, company, address, and other demographic info of the user, etc.

The database is a text file that has field names on the first line and the subsequent lines below contain the data. Its tab delimited and each line is separated by a carriage return.

Any ideas? Thanks in advance.

Edit: The speed concern brought up by Eddie is definitely a valid one. So, to work around the need for PHP flat file database interaction I have instead used WebDNA to pull up the database data on the page prior to my PHP page. I then passed the data from the WebDNA page to the PHP page via form post. So there is 1 extra step in the payment process for the customer but the data is pulled up in a standard and quick way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:16:57+00:00Added an answer on May 28, 2026 at 1:16 am

    The database is a text file that has field names on the first line and the subsequent lines below contain the data. Its tab delimited and each line is separated by a carriage return.

    That sounds like a CSV type of file. PHP has functions and classes to deal with those, you only need to specify the field delimiter and take a bit care about the line delimiter: fgetcsv­Docs

    Following Eddie’s lead, the function would look something like:

    function get_data_field_from_tsv($id_to_look_for, $filename){
       $id_field_im_interested_in_position = '0'; //if it's the first field in the line
       $row = 1;
       if (($handle = fopen($filename, "r")) !== FALSE) {
          while (($data = fgetcsv($handle, 0, "\t")) !== FALSE) {
             $row++;
             if (trim($data[$id_field_im_interested_in_position])==$id_to_look_for){
                fclose($handle);
                return $data;
             }
          }
          fclose($handle);
          return false;
       }
    }
    

    So a sample use for the following file “testfile.db”:

    ID  SECOND  THIRD   FOURTH
    12  test2   test3   test4
    13  test22  test33  test44
    14  test222 test333 test444
    

    would be:

    $data = get_data_field_from_tsv(14, '/path/to/testfile.db');
    print_r($data);
    

    Which results in:

    Array
    (
        [0] => 14
        [1] => test222
        [2] => test333
        [3] => test444
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for the most simple way to download a file in C++
I am looking for the most efficient/direct way to do this simple C/C++ operation:
I'm looking for the most efficient/simple way to run a script (we'll call it
I am looking for the most simple way to control JTextPane (its inner text)
I'm looking for a (preferably simple) way to find and order the most common
I'm looking for a basic software for statistical analysis. Most important is simple and
I'm looking for most elegant way to ajaxify my forms (with jQuery). How do
I'm looking for the most ideal data structure (for performance and ease of use)
I am looking for the most standard way to achieve modal dialogs in ASP.NET
I am looking for a most efficient way to re-use widgets with different selectors...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.