I need to query my MySQL database and store all rows that are returned within the $dadosBrutos
variable. The purpose is for each line to be separated by the character "§", for example: nomeCliente1,telefoneCliente1§nomeCliente2,telefoneCliente2§nomeCliente3,telefoneCliente3
and so on.
The data will be obtained with the SELECT * FROM tbClientes
command, but I have no idea how to separate one line from the other and store them within the $dadosBrutos
variable.
I tried to make this code with Do...While
, but I have no idea how to continue.
For now I have the following code:
if($qtdeClientesCadastrados > 0) {
$contador = 0;
do {
} while ($contador < $qtdeClientesCadastrados);
} else {
echo "zero_clientes_cadastrados";
}
Notes:
-
The variable
$qtdeClientesCadastrados
has already been declared in the snippet above the posted code and stores the number of clients that are registered intbClientes
of the database; -
The entire database connection system is already up and running correctly;
-
If there is a better method to make code without being
Do...While
, it is also useful, since at the end it is possible to give the commandecho $dadosBrutos;
.