After inclusion, you must enter the JOIN clause. Like this:
$sql="select pic, userid from user_details inner join wp_users on (wp_users.id=user_details.userid) limit $recordstart, $pagesize";
But the real problem is that you have more than 1 entry in user_details for each corresponding entry in wp_users (or vice versa). INNER JOIN forces the database to do the Cartesian product of user_details and wp_users . Then the result table is filtered by the current WHERE clause (wp_users.id = user_details.userid). Depending on your needs, you can use GROUP BY or DISTINCT if you want to get only unique records. For example, if you need userid be unique:
$sql="select pic, userid from user_details inner join wp_users on (wp_users.id=user_details.userid) group by userid limit $recordstart, $pagesize";
source share