php - How can i display one link instead of multiple links? -
<?php include 'precode.php'; include 'header.php'; echo '<body><div class="standardlayout">'; include 'systemmenu.php'; echo '<h4>all charges</h4>'; $user = unserialize($_session['user']); $query = "select * billingitems userid= ' ".$user->userid. " ' order deliverytimestamp desc"; $result = mysqli_query($db, $query); while($row = mysqli_fetch_array($result)) { echo '<p>'; echo '<a href="billinghistory1.php?deliverytimestamp=' .$row["deliverytimestamp"]. '">'. ' order delivered on' . '</a>' .$row['deliverytimestamp'] ; } echo '</div></body></html>'; $_session['user'] = serialize($user); include 'footer.html'; ?>
output of above file:
charges order delivered on2015-05-06 13:26:50 order delivered on2015-05-06 13:26:50 order delivered on2015-05-06 13:26:50 order delivered on2015-05-03 22:11:23 order delivered on2015-05-03 22:11:23 order delivered on2015-05-03 22:11:23 order delivered on2015-05-03 22:11:23
if see output notice first 3 links same , last 4 same.
i need reduce multiple links one.
want display 2 links 1 each.
to that, need use if statement inside while loop. if deliveredtimestamp
same don't display otherwise display it. please help.
why not try adding unique deliverytimestamps array , rendering links those?
$timestamps = array(); while($row = mysqli_fetch_array($result)){ if ( !in_array($row['deliverytimestamp'], $timestamps)) { array_push($timestamps, $row['deliverytimestamp']); } } foreach ($timestamps $timestamp) { echo '<p>'; echo '<a href="billinghistory1.php?deliverytimestamp='.$timestamp.'">'. ' order delivered on' . '</a>' .$timestamp ; echo '</p>'; }
Comments
Post a Comment