Advanced Search

Results 1 to 3 of 3

Thread: To read data from CSV file and print the values in Select field of a form

  1. #1
    Join Date
    Nov 2008
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default To read data from CSV file and print the values in Select field of a form

    Hello everyone,

    I am reading a .csv file:

    <?php

    $file = fopen("groups.csv","r");

    while(!feof($file))
    {
    $groups2 = fgetcsv($file,",");
    print_r($groups2);
    }

    fclose($file);

    ?>

    The file is read successfully. But now i need to call this file in another file and the groups fetched from this file are to be placed in a select field of the form.

    Can anyone please help me how to do this?

    Thank you.

  2. #2
    Join Date
    Sep 2008
    Posts
    56
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Default

    Hi,

    This is simple..... :-)!

    Start a form tag just before the while loop and in the while loop where you are displaying value of Group2 there add this line: -

    echo ("<input type=text name= ". $i . " value=" . $group2 . ">");

    Where $i will be a counter to name each text box differently, after the loop create a hidden filed and set value of $i as its value. Now when you will submit this form the value of this hidden field will tell you how many text boxes where created and then you can access them all.

    Hope this makes sense!

    Cheers,

    ~Maneet
    LeXolution IT Services
    Website Design Services

  3. #3
    Join Date
    Nov 2008
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Resolved

    I go it the way you said

    Thank you.

Bookmarks

Posting Permissions

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