How to copy . php file

Asked

Viewed 64 times

0

I have a database with the fields: name I have an a.php file that fetches the name data from mysql and fills in a certain area of the page (content).

What I want is that as long as there is data in the database in the "name" column the a.php file is copied X times, changing its name and content.

Example: the A.php file is copied to ana.php and changes the contents of the page itself to "Ana"

How can I do it?

  • I’m sorry if I’ve misunderstood, but what you’re trying to do seems to be a gambit. Could you detail what your application is and what exactly you’re trying to do?

1 answer

0


You can do this with the fopen and fwrite:

<?php
    while ($row = $query->fetch_assoc()){ //Onde $query possui um objeto mysqli_result
        $nome = $row['nome'];
        $arquivo = fopen("$nome.php", "w");
        fwrite($arquivo, $nome);
        fclose($arquivo);
    }
?>
  • Thanks for the reply Francisco. How should I edit the contents of the file?

  • The fwrite writes in the archive.

  • Thanks again francisco. I’ll take the test to see how it goes :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.