Jaowat Raihan Jaowat Raihan - 1 year ago 52
PHP Question

Reading from files and store it into textboxes

This is my file data


What i want to do is that store every string seperated by '-' and store it into HTML textboxes:

<input type="text" name="username" value="Alex"
<input type="text" name="date of birth" value="10/9/2008" />

So far i have tried this. This 'Alex' and '10/9/2008' should be read from the upper mentioned file. I could managed to store different strings into array. But i have no idea how to put these values into different textboxes. Below, is my php code where i tried to read from a file and strode values into array

$myfile = fopen("records.txt", "r");///This is my file
while(!feof($myfile)) {
$array = explode("-",$line);

Answer Source

Your $array must contain something like this:

Array([0]=> Alex, [1]=>10/9/2008,[2]=>male, .......)

So, username Alex is stored in $array[0] and date of birth 10/9/2008 is stored in $array[1]

<input type="text" name="username" value="<?php echo $array[0]; ?>" />
<input type="text" name="date of birth" value="<?php echo $array[1]; ?>" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download