Jump to content

Recommended Posts

im using the following to get get the followers of currently viewing user, but when i run this code , it gives me over 20000 times same username which is the only one who following that user ;  really need help my head is not working :P ,,, i have tried to use inner join but not working (or i don't know how to make it work).

 

code :

 

<?php 
$stmt = $mysqli->prepare("SELECT follow_id from follow_user WHERE id= ?"); 
        $stmt->bind_param('s', $viewuser); // Bind "$user_id" to parameter.
        $stmt->execute(); // Execute the prepared query.
        $stmt->store_result();
$stmt->bind_result($follow_id); // get variables from result.
while($stmt->fetch()) {
$stmt = $mysqli->prepare("SELECT id,username,profilepic from members WHERE id= ? LIMIT 1"); 
        $stmt->bind_param('s', $follow_id); // Bind "$user_id" to parameter.
        $stmt->execute(); // Execute the prepared query.
        $stmt->store_result();
if($stmt->num_rows == 1) {
$stmt->bind_result($id,$followusername,$followpic); // get variables from result.
 } ?>
<?php echo $followusername; ?>
 <?php
 }
 ?>
Edited by ArshSingh
Link to comment
https://forums.phpfreaks.com/topic/287586-mysqli-prepare-stuck-in-results/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.