Hi Guys i got two tables the first on is called "posts" and looks like this
id picture title description poster ip posterid .....
123 img-2.jpg Title 1 Desc 1 Poster xx 1
The second table is called "love" and looks like this
id ip userid postid created
1 xx 1 123 date
This is how my MySQL Query looks actually:
<?php
// Get records from the database
$query = $db->query("SELECT * FROM posts ORDER BY id DESC LIMIT 10");
if($query->num_rows > 0){
while($row = $query->fetch_assoc()){
$postID = $row['id'];
?>
<!-- POST ITEM START -->
<div class="post-item">
<div class="post-asset image">
<img src="uploads/<?php echo $row['picture']; ?>">
</div>
<div class="post-header">
<h3 class="post-title"><a href="#" data-loader="show"><?php echo $row['title']; ?></a></h3>
<span class="post-category">
<a class="favorite-button" href="#" data-post="<?php echo $row['id']; ?>" data-userid="<?php echo $_SESSION['user_id'];?>"><span class="favorite-button-icon fa fa-star-o"></span></a>
</span>
<span class="post-date font17"><i class="fa fa-clock-o"></i> <?php $timeago=get_timeago(strtotime($row['created'])); echo $timeago;?></span>
<span class="post-comments font17"><i class="fa fa-comments-o"></i> 1,3k Reaktionen</span>
</div>
<div class="post-footer">
<a href="#" class="post-author">
<span class="author-img"><img src="img/avatar.png"></span>
<span class="author-name">OnePost von<b><?php echo $row['poster']; ?></b></span>
</a>
<div class="post-extra">
<!--<div class="add-favorite" id="heart-container"><span class="lovecount">112</span><input data-post="123" data-user="Jessica Jones" type="checkbox" id="toggle" onclick="myFunction(this)" checked><div id="twitter-heart" class=""></div></input></div>-->
<div class="add-favorite" id="heart-container"><a href="#" title="Alle Loves anzeigen"><span class="lovecount"><?php echo $row['loves']; ?></span></a>
<!--<input data-post="<?php echo $row['id']; ?>" data-userid="<?php echo $_SESSION['user_id'];?>" type="checkbox" id="toggle" class="toggle love" onclick="myFunction(this)">-->
<input data-post="<?php echo $row['id']; ?>" data-userid="<?php echo $_SESSION['user_id'];?>" type="checkbox" id="toggle" class="toggle">
<div id="twitter-heart" class=""></div></input></div>
<div class="post-share"><i class="fa fa-share-alt"></i>
<div class="social-links">
<a href="#" class="share-facebook social-links-a" data-network="Facebook" data-post="<?php echo $row['id'] ?>" data-url="https://onepost.eu/neu/post.php"><i class="fa fa-facebook"></i></a>
<a href="#" class="share-twitter social-links-a" data-network="Twitter" data-post="<?php echo $row['id']; ?>" data-url="https://onepost.eu/neu/post.php"><i class="fa fa-twitter"></i></a>
<a href="#" class="share-google-plus social-links-a" data-network="Pinterest" data-post="<?php echo $row['id']; ?>" data-url="https://onepost.eu/neu/post.php"><i class="fa fa-pinterest"></i></a>
<a href="#" class="share-whatsapp social-links-a" data-network="WhatsApp" data-post="<?php echo $row['id']; ?>" data-url="https://onepost.eu/neu/post.php"><i class="fa fa-whatsapp"></i></a>
</div>
</div>
</div>
</div>
</div>
<!-- POST ITEM END -->
<div class="form-mini-divider"></div>
<?php } ?>
<div class="form-divider"></div> -->
<div class="show_more_main" id="show_more_main<?php echo $postID; ?>">
<button id="<?php echo $postID; ?>" class="show_more button circle block green">Mehr OnePosts</button>
<button class="postloading button circle block green" style="display: none;">Lade...</button>
</div>
<?php } ?>
What i want to get done is now to get to know if the actual user with its Session id which is also the user id hast liked the post or not and display it in if or if not.