It is not feasible to determine whether there is bad practice in the presented code.
The question is vague and creates a disconnected sense.
Something closer to "bad practice" may be the style used in PHP syntax.
ex:
foreach($dadosbanco as $value):
endforeach
could be
foreach ($dadosbanco as $value) {
}
I believe that this style is more readable. I prefer to avoid alternative forms. Because it only makes the code more complex, especially for beginners in the language. But it is personal opinion and can ignore. Just do not ignore that there are standards defined and accepted by the PHP community np worldwide. Currently there is an effort to spread the "Psrs". See official website: http://www.php-fig.org/psr/
Just don’t confuse this as if it were a law, because no one is required to use the patterns suggested by this site and neither should we judge the style and patterns of other people’s codes compared to "Psrs".
Another point is to invoke echo
in a repeat loop. It is usually slower than concatenating and giving only one echo
. But this is not very relevant and not considered bad practice.
Something that I imagine can come close to the point of the question is that maybe you’ve heard something about avoiding mixing HTML, PHP, etc. The MVC thing.
Still, the way you put it there’s no relevant bad practice.
Just to give an allowance for my answer, do you imagine any problem that might occur doing this? Someone said it’s bad?
– Maniero
In another Post I commented on using a static method to do this and I received responses not recommending so I wanted to know why. Pq to my view this would make it much easier the work type has an organ table that always has a new and several screens of the system uses this select ai manually I always go in HTML and add on each screen and so would not need more.
– Thalles Daniel
Now it’s getting better, you can [Dit] the question by posting a link referencing that answer.
– Maniero
@bigown after the comment I was even more confused... Thailes you wonder if it is bad practice to do so statically or dynamically?
– Jorge B.
@Jorge B. The serious static method of the class to invoke it to execute the dynamic select.
– Thalles Daniel
@Thallesdaniel ask [Edit] your question and add this information and if possible put the example of this code.
– Jorge B.
@Thallesdaniel did not understand...
– Jorge B.
@bigown thanks for editing maybe now it became clear the goal. The reason for the negativations was because she n was clear?
– Thalles Daniel