$sel_ms="SELECT * from users INNER JOIN likes ON users.id=likes.user_id and likes.post_id='$id'";
i have a problem with my code when i type this sql on database as for example
$sel_ms="SELECT * from users INNER JOIN likes ON users.id=likes.user_id and likes.post_id='470'";
it returns true i mean two person who have liked my post but inside my brauzer i faced with the problem and can not find exact persons who liked it it shows me all USERS I am passing parameters properly and it works for each post and for each button those are the files which i worked on maybe i have a proble with loops but i do not know why it is not returning me the exact users?
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<?php
//messaglarin cixdigi yer
$sel_msg="SELECT *FROM messages LEFT JOIN users ON messages.user_id=users.id ORDER BY 5 ASC LIMIT 7";
//$sel_msg="select * from messages LEFT JOIN users ON messages.user_id=users.id ORDER BY 5 ASC LIMIT 7";
$run_msg=mysqli_query($con,$sel_msg);
while($row_msg=mysqli_fetch_array($run_msg)){
//$id=$row_msg['id'];
$id = $row_msg[0];
$user_id=$row_msg['user_id'];
$msg2=$row_msg['messages'];
$date=$row_msg['date'];
$username=$row_msg['f_name'];
$count_like=$row_msg['like_p'];
$sel_ms="SELECT * from users INNER JOIN likes ON users.id=likes.user_id and likes.post_id='$id'";
$run_ms=mysqli_query($con,$sel_ms);
while($row_ms=mysqli_fetch_array($run_ms)){
$name=$row_ms['f_name'];
echo $name."<br>";
}
}
?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>;
> And span which holds id=$id and button modal this contains id of each post when i click it returns me the id of each post
<div id="loaded_msg">
<form method="POST">
<p>
<?php
echo"
<button type='button' id='#exampleModal' class='btn btn-primary' style='margin-left:530px; margin-top:-35px;' data-toggle='modal' data-target='#exampleModal'>
+
</button>";
?></p>
</form>
</div>
wHEN i click on button it should return me users who has liked it
database looks like this
table->likes has (l_id,post_id,user_id)
table->users has (id,f_name,etc)
Aucun commentaire:
Enregistrer un commentaire