Alex-

This is very basic PHP.

> I have some variables stored in plain text in a text file. Unfortunately I
> am not going to be able to use SQL to solve this one, since that server is
> not running it. Anyway.
> 
> The text file looks like this (everything between the *):
> *
> SAVINGS=type1
> FILTER=disabled
> SPOOL=category1
> *
>
> I use a form to edit this text file. SAVINGS and SPOOL are 'select' form
> items with multiple options. FILTER is a 'radio' form item with two options.
> 
> I was wondering if anyone knew how to make the text file pass the variables
> into the form that i use to edit the text file... confusing?

First, you need to get the data from the file and make the items
useful:

<?
$ary = file("myfile.file");

foreach($ary as line) {
  # break up the line
  list($key,$value) = explode("=",$line);

  # Take off that pesky newline
  $value = substr($value,0,-1);

  $data[$key]=$value;
}
?>

Now your values are accessible as $data["SAVINGS"], etc.

So... when building the HTML...

<?
print '<INPUT TYPE="TEXT" NAME="savings" VALUE="' .
$data["SAVINGS"] . "'>";
?>



Daniel J. Lashua


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to