Html code repeats in parsing mysql results
Posted: 25 May 2016, 19:46
I have this php code:
The problem is that html value repeats. See on: mluci.com/d/cont.php
Code: Select all
if ($result->num_rows > 0) {
if($row['stare'] =='sell') $html .='<h4 class="telefon2">'.$row['stare'].'</h4>';
else if($row['stare'] =='rent ') $html .='<h4 class="telefon3">'.$row['stare'].'</h4>';
// afisaza datele pentru fiecare rand din $result
while($row = $result->fetch_assoc()) {
if($row['stare'] =='sell') $html .='<h4 class="telefon2">'.$row['stare'].'</h4>';
else if($row['stare'] =='rent ') $html .='<h4 class="telefon3">'.$row['stare'].'</h4>';
echo '<div class="box-body box box-solid fa fa-text-width box-header with-border">
<div class="pull-left image">
<img class="img-circle" src="avatar.png" alt="User Image" width="32" height="32"></img>
<p style="text-align:center">'.$row['email'].'</p>
</div>
<h4 class="host_link">'.$row['importanta'].'</h4>
<h4 align=\"left\" class="host_link">'.$row['stare'].'</h4>
<br></br> '. $html .'
<h4 align=\"left\"><strong>Title</strong>: '.$row['ids'].'</h4>
<h4 align=\"left\"><strong>Descriere</strong>: '.$row['descriere'].'</h4>
<h4 align=\"left\"><strong>Email</strong>: '.$row['email'].'</h4>
<a href="send-message.php?user='.$row['memberid'].'&type=requiment" target="_blank"><img src="http://mluci.com/d/Message.png"></img></a>
<a href="tel:+40726106381"> <img src="http://mluci.com/d/call.png"></img></a>
<a href="ticket.php?idt='.$row['ID'].'&type=Available" target="_blank"><img src="http://mluci.com/d/details.png"></a>
<a href="copy.php?descriere='.$row['descriere'].'&title='.$row['ids'].'"><img src="http://mluci.com/d/copy.png"></img></a>
</div> ';
}
}
else {
echo '0 results';
}