look at the Basic Chord Fingering post at the top of this forum page for a list of all the basic chords in every key and in every inversion.
In order to play the right inversion of a chord, use the inversion where the melody note is the top note of the chord. So, using a C major chord, if the melody note is E, then play G-C-E, which is the 2nd inversion of the C major chord. If the melody note is C, then play E-G-C, which is the 1st inversion of the C major chord. If the melody note is G, then u play
C-E-G, which is the root position of the C major chord.