+1 vote
by
So, how do I make sure that I get the values from the database, formed into a list and then output to a txt file. As I did:
PutListDB('test.txt', (while ($row = $result->fetch_assoc()) {
$row['first_name'].' '.$row['last_name'].' '.$row['reg_data'].PHP_EOL;
}));
I know I probably won't get what I want that way, but I just don't know how else I can implement it.
!The list should be formed and only write down already.
by
Here you have rather output to a txt file, get the data values from the database, form a list and then
by
Well, I told you - take turns, as I wrote.
Let's do it together
first get the values from the database
by
FanatPHP Well, okay, how can I form this list?
by
Yes, the thing is that with the code I cited, I get
Syntax error, unexpected T_WHILE
by
Wait a minute with the list!
Your problem is that you are in a big hurry.
And you have to do everything step by step. And you yourself in the question you wrote it all down. three steps:
- values were obtained from the database,
- formed into a list of
- and then output it to a txt file

You have to start with the first one.

2 Answers

0 votes
by
 
Best answer
Try it this way:
<?php
PutListDB('test.txt', function() {
$s='';
while (null !== ($row = $result->fetch_assoc())) {
$s.=$row['first_name'].' '.$row['last_name'].' '.$row['reg_data'].PHP_EOL;
}
return $s;
});
?>
+1 vote
by
Maybe we should get the values from the database, form them into a list, and then output them to a txt file?
by
you just take it one step at a time.
first get the values from the database
by
That's what I'm trying to get, but I don't know how to generate a list with all the right values.
by
interchangeably
...