Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CSV, retrieving and editing data

    Hey,

    I am attempting to let my users edit a CSV file from their control panel. They all should have 2 "slots". I am using the following format:
    Code:
    "Laur3ns1","world","Laur3ns","190.06752899480915","69.0","1643.384470515287","-32.700108","184.04663"
    "Laur3ns2","world","Laur3ns","-1607.703077719658","63.0","1523.51365067294","29.54973","-40.56433"
    "Aronnn1","world_nether","Aronnn","-203.0878960285693","64.0","0.49427347759672624","39.3","-175.35004"
    What it should do is it should be able to check how many slots you have used, in this case the person Laur3ns used 2 of them and Aronnn only 1. I can develop a panel which allows you to update them both but do not know how to check if they are used and if not add one, and if it is used, update it. The current code I am using to output it is:
    PHP Code:
    <?PHP
    $file_handle 
    fopen("warps.csv""r");
    while (!
    feof($file_handle) ) {
    $line fgetcsv($file_handle1024);
    print 
    $line[0] . $line[1] . $line[2] . $line[3] . $line[4] . $line[5] . $line[6] . $line[7] . "<BR>";
    }
    fclose($file_handle);
    ?>
    If anybody could help me I could highly appreciate it,
    Aron

  • #2
    JV-
    JV- is offline
    New Coder
    Join Date
    Oct 2011
    Posts
    19
    Thanks
    0
    Thanked 3 Times in 3 Posts
    I suggest using a database for things like this. You can easily manipulate data like this in a database and create easy to use interfaces for it. You can also export data to CSV if you need to.

  • #3
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for your reply,
    I am currently using a plugin that outputs in a CSV file and can only be changed through CSV. I already thought of porting it to MYSQL but since the source has not been released I need to do it with CSV (the plugin is writen in java).

  • #4
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    http://php.net/manual/en/function.fgetcsv.php

    That could be something that applies. Have a good look through it.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •