php - Show more than one result from JOIN with if statement -


i have join, gets me more on result:

at.tipo atividade, at.data datacadastro, at.user usercadastro,   left join atividades @         on (at.produto = '$produto')         , (at.tipo = 'cadastra' or at.tipo = 'revisado')   

and have: if string = 'cadastra' shows something, if string = 'revisado' shows else.

<?php      if ($row['atividade'] == 'cadastra') {           echo '<div id="user-img">';         echo '<img src="http://'.$row['imguser'].'"/></div>';            echo '<div id="user-cadastro" class="greytxt">';                             echo 'cadastrado por <br>' .$row['usercadastro']. '<br>em ';         echo $row['datacadastro']. '</div>';     }  ?>  <?php      if ($row['atividade'] == 'revisado') {           echo '<div id="user-img">';         echo '<img src="http://'.$row['imguser'].'"/></div>';            echo '<div id="user-cadastro" class="greytxt">';                             echo 'cadastrado por <br>' .$row['usercadastro']. '<br>em ';         echo $row['datacadastro']. '</div>';     }   ?>     

the problem is, it's showing first result, , not all.

how can display results?

edit:

i have join inside big query, give me other important rows. want 1 result principal query (where = $produto), , want more results join table.

$rows = $result->num_rows;    ($j = 0; $j < $rows; ++$j) {     $result -> data_seek($j);     $row = $result->fetch_array (mysqli_assoc);  ?> 

my result should this, join shows row 'cadastra'. my result should this, join shows row 'cadastra'.

use $result->fetch_array (mysqli_assoc) inside while loop

while ($row = $result->fetch_array (mysqli_assoc)) {   if ($row['atividade'] == 'cadastra')         {      echo '<div id="user-img">';   echo '<img src="http://'.$row['imguser'].'"/></div>';    echo '<div id="user-cadastro" class="greytxt">';                     echo 'cadastrado por <br>' .$row['usercadastro']. '<br>em ';   echo $row['datacadastro']. '</div>';             } ?>   <?php if ($row['atividade'] == 'revisado')         {      echo '<div id="user-img">';   echo '<img src="http://'.$row['imguser'].'"/></div>';    echo '<div id="user-cadastro" class="greytxt">';                     echo 'cadastrado por <br>' .$row['usercadastro']. '<br>em ';   echo $row['datacadastro']. '</div>';             } } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -