Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $sql2 = "SELECT * FROM likes WHERE id_post='$row[id_post]'";
- $result2 = $conn->query($sql2);
- $totalLikes = (int) $result2->num_rows;
- ?>
- <span><?php echo $totalLikes; ?></span>
- <!-- </a> -->
- <?php
- if ($row['type'] == 'friend') {
- $sql3 = "SELECT * FROM friends_comments WHERE id_post='$row[id_post]'";
- } else {
- $sql3 = "SELECT * FROM comments WHERE id_post='$row[id_post]'";
- }
- $result3 = $conn->query($sql3);
- $totalComments = (int) $result3->num_rows;
- //Displaying Liker's Profile Image and First Name
- $liker = "SELECT * FROM users WHERE id_user IN (SELECT id_user FROM likes WHERE id_post='$row[id_post]')";
- $likerResult = $conn->query($liker);
- if ($likerResult->num_rows > 0) {
- $likerId = $likerFirstName = $likerPic = array();
- $l = 0;
- while ($likerRow = $likerResult->fetch_assoc()) {
- echo '<ul class="friends-harmonic">';
- $likerId[] = $likerRow['id_user'];
- $likerFirstName[] = $likerRow['firstName'];
- $likerPic[] = $likerRow['profilePic'];
- $likerTotal = $totalLikes - 2;
- if ($l == 0) {
- $likerName = "";
- } else if ($l == 1) {
- $likerName = $likerFirstName[0] . " liked this.";
- } else if ($l <= 3) {
- $likerName = $likerFirstName[0] . ", " . $likerFirstName[1] . " liked this.";
- } else {
- $likerName = $likerFirstName[0] . ", " . $likerFirstName[1] . " and " . $likerTotal . " more liked this.";
- }
- echo '<li>
- <a href="profile.php?id=<?php echo $likerId[$l]; ?>">
- <img src="<?php echo $likerPic[$l]; ?>" alt="<?php echo $likerFirstName[$l]; ?>">
- </a>
- </li>';
- $l++;
- if ($l > 5) {
- break;
- }
- echo '<div class="names-people-likes">'.$likerName.'</div>';
- echo '</ul>';
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement