I have a issue with the code below what I am trying to get the image from gifts table with matching the user_gifts id with the gifts_id but can not seam to get it right anyone god any ideas thanks.

public function get_my_gifts($user_id) {
        global $db;
        $my_gifts = [];
        $get_my_gifts = $db->query(sprintf("SELECT gifts.image FROM users_gifts INNER JOIN gifts ON `users_gifts`.gift_id = `gifts`.gift_id WHERE users_gifts.to_user_id = %s", secure($user_id, 'int') )) or _error("SQL_ERROR_THROWEN");

        if($get_my_gifts->num_rows > 0) {
            while($my_gift = $get_my_gifts->fetch_assoc()) {
                $my_gifts[] = $my_gift;
            }
        }
        return $my_gifts;

}

Yours
Simon

Hey Si.

You'll need to show some data from your tables and how it should combine, then we can fix the query.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.