Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6

Thread: PHP & CSV file

  1. #1
    Member Cranky's Avatar
    Join Date
    Aug 2002
    Location
    Durham, UK
    Posts
    34
    Member #
    171
    Hi,

    I have a list of hundreds/thousands of number ranges in CSV format.

    e.g.

    ABHEK,100000000,100020000 (e.g. anything between and inc. those two numbers)
    ABHEL,100040000,100060000

    The first group of letters represents data we do not need as part of this script, but are required in the CSV file.

    I need a php script (possibly with mySQL backend) that will allow a user to enter a number in a webpage then the script check to see if their number is included in one of the ranges of the CSV file.

    If it is - I want it to say so and move to the ordering system.
    If it isn't - I want it to say so and move to a pre-ordering system.

    The CSV file changes regularly and so must be easily updateable.

    I have very very little experience with php and am unsure where to start - any advice would be appreciated.

    Thanks.
    Thanks,

    Andrew Cranson
    Transnexis Group

  2.  

  3. #2
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    Is there is any kind of order in CSV file?

    A rather crude way would be like this:

    PHP Code:

    $input 
    $_POST['input'];

    $CSV_lines file("file.csv");

    for(
    $i 0$i sizeof($CSV_lines); $i++)
    {
        if(
    in_array($inputexplode(",",$CSV_lines[$i]))
        {
          
    //found.
          // redirect to ordering system.
        
    }
        else
        {
          
    // not found , redirect to pre-ordering system.
        
    }

    There and Back Again :Ogre:

  4. #3
    Member Cranky's Avatar
    Join Date
    Aug 2002
    Location
    Durham, UK
    Posts
    34
    Member #
    171
    Is there is any kind of order in CSV file?
    The numbers are in numerical order - but obviously each line represents a range and between ranges I want it to show as no result.

    Understand?

    Thanks
    Thanks,

    Andrew Cranson
    Transnexis Group

  5. #4
    Member Cranky's Avatar
    Join Date
    Aug 2002
    Location
    Durham, UK
    Posts
    34
    Member #
    171
    It's a 1.5MB CSV file btw - so would it work efficiently processing it via PHP?
    Thanks,

    Andrew Cranson
    Transnexis Group

  6. #5
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    It wouldn't. My suggestion is to throw the file into a mySQL table. Then one query will do the job.
    There and Back Again :Ogre:

  7. #6
    Member Cranky's Avatar
    Join Date
    Aug 2002
    Location
    Durham, UK
    Posts
    34
    Member #
    171
    Any ideas how this can be done? I'm kinda new to php & mySQL playing nicely together.
    Thanks,

    Andrew Cranson
    Transnexis Group


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:34 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com