Answer the question
In order to leave comments, you need to log in
Writing a loop to a variable?
Hello. I'm trying to write the output from the database to a variable.
In a DB about 30 lines and 10 columns, I want to write down all variables in one and to write down in a file
But, in the current result writes down only the last line.
$result = mysqli_query($link, "SELECT * FROM `table`");
while($result_show = mysqli_fetch_array($result)){
$symbol = $result_show['symbol'];
$data = '
Перменная1: '.$symbol.'
';
file_put_contents($file, $data);
echo $data;
}
Answer the question
In order to leave comments, you need to log in
Страшный конечно запрос. Не делайте так никогда, используйте PDO и биндинги.
Покажите структуру таблицы, тип и кодировку поля url, набор данных для примера и содержимое $url
file_put_contents($file, $data, FILE_APPEND);
"If the file filename already exists, the data will be appended to the end of the file instead of being overwritten."
https://www.php.net/manual/ru/function.file-put-co...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question