2
I have the code below in the PHP class.However, the Array is only returning one value (position [0]) in the table. Executing the SQL statement in Mysql, return two lines. Could anyone tell where the error is? Thankful.
if($consUsu->execute()){
$usuDados = $consUsu->fetchAll(PDO::FETCH_OBJ);
foreach($usuDados as $usuario){
$usuarios = $usuario->funcNome."/".$usuario->funcRg."/".$usuario->deptDescricao."/".$usuario->divDescricao;
$usuarios = explode("/",$usuarios);
echo '<table width="100%" border="2px solid" bordercolor="#000000">';
echo '<th width="">NOME</th>';
echo '<th>R.G.</th>';
echo '<th>DEPARTAMENTO</th>';
echo '<th>DIVISÃO</th>';
echo '<th>CARGO</th>';
echo '<tr width="100%">';
for($x = 0; $x < 4; $x++){
echo '<td width="auto">'.$usuarios[$x].'</td>';
}
$teste
comes from where? and does what/?– rray
Excuse me. I put this name only to make a test that ended up not working. The right name of this variable is: $user.
– Vanderci
I would ask just that @rray. What if I remove that line? And in FOR
for($x = 0; $x < 4; $x++)
I predict problems, because it goes to element 3 of the array, and if you have no more than one object or have more than 3 objects?– Giancarlo Abel Giulian
Please edit your question with the correct code?
– Giancarlo Abel Giulian
This < 4 is related to the number of columns that will be inserted in the <table>; My select returns four columns. So < 4.
– Vanderci
If you have no reason to use an object, pq does not use a numeric array instead? no way that
explode()
ai.– rray
I’m using explode() to dismember the columns returned by select and play them in the <table> columns. Otherwise, the result is launched into a single cell of the table. ?
– Vanderci