ArshSingh Posted April 7, 2014 Share Posted April 7, 2014 (edited) 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 ,,, 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 April 7, 2014 by ArshSingh Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.