octacon Posted April 15, 2008 Share Posted April 15, 2008 Hope someone can help me out or steer me in the right direction. I have here a comma delimited text file being read to an array (at least I think I do) and i want the array elements to populate 3 textboxes on the form when a user clicks on open button. How do I go about doing this. Also I need to be able to move backward and forward through the array. I am not even sure if the way I am going about it is correct so I would appreciate any pointers. I have supplied my code so far...please let me know what you guys think i should do. Thanks! <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Players</title> </head> <body> <h1>Players</h1> First Name: <input type="text" name="txtFirstName" size="12" value="$CurPlayer"> <p>Last Name: <input type="text" name="txtLastName" size="12"> </p> <p>Salary: <input type="text" name="txtSalary" size="10"> </p> <input type="button" name="btnOpen" value="Open"> <input type="button" name="btnBack" value="<"> <input type="button" name="btnForward" value=">"> <input type="button" name="btnClose" value="Close"> <?php $Players= fopen("B1Players.txt", "r"); $Count = 1; $CurData = fgetcsv($Players, ","); while(!feof($Players)){ $CurPlayer = explode(", ", $CurData); $FirstName = $CurPlayer[0]; $CurData = fgets($Players); ++$Count; } fclose($Players); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted April 15, 2008 Share Posted April 15, 2008 Well, you're going to need some javascript to handle the buttons to move things around. But before anyone could help you, we'd need to know a little more about the structure of the text file. You mention moving forwards and backwards. Im assuming this is through the data - in which case, how is is stored? Does the text file contain a long list of values, all comma separated? Or is there 3 values on each line? I would suggest having PHP read the file into an array in javascript. You would then be able to move backward and forward though the data nicely. Quote Link to comment Share on other sites More sharing options...
octacon Posted April 15, 2008 Author Share Posted April 15, 2008 The text file indeed has only 3 values on each line separated by commas. Its just some sample data that i am using to get this thing working. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.