In article <009201c21dd4$a1c96d80$9600a8c0@ady> , [EMAIL PROTECTED] (Adi)
wrote:

>how to make a changerate.php file for:
>
>Read a file: rate.php
>Find string : 'USD' => '0.33'
>Put '0.33' value in an editable textbox. I can change this value, let's say 
>to 0.35;
>I Have an Update Button, when I press, the new value (0.35) change with old 
>value (0.33) in rate.php like this: 'USD' => '0.35'

First, don't use "help pls!" as a subject.  That will get ignored by many
readers.

Secondly, you *REALLY* should put this stuff into a DATABASE, not a file. 
Honest.  It's going to be much *EASIER* if you do.

Here's the PHP for what you think you want, but you really don't:

<?php
  if (isset($rates)){
    $file = fopen('rate.php', 'w') or die("Unable to record new rate
information.  Sorry!");
    while (list($country, $rate) = each($rates)){
      $line = "'$country' => '$rate'";
      $charcount = fputs($file, $line);
      if ($charcount != strlen($line)){
        echo "Only wrote $charcount out of ", strlen($line), "
characters!<BR>\n";
      }
    }
  }
?>
<FORM ACTION=<?=$PHP_SELF?> METHOD=POST>
<?php
  $rates = file('rate.php') or die("Unable to look up rate information. 
Sorry!");
  while (list(,$line) = each($rates)){
    $parts = explode('=>', $line);
    $country = trim($parts[0]);
    $rate = trim($parts[1]);
    $country = substr($country, 1, -1); # Strip off apostrophes.
    echo "$country <INPUT NAME=rates[$country] VALUE=$rate><BR>\n";
  }
?>
<INPUT TYPE=SUBMIT>
</FORM>

-- 
Like Music?  http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to