Ionic bonds are created by electrochemical attraction between atoms of opposite charges, while molecular bonds (aka covalent bonds) are created by atoms sharing electrons in order to complete the rule of octet.
An ionic compound is created through the electrochemical attraction between a positively charge metal or cation and a negatively charged non-metal or anion. If the charges of the cation and anion are equal and opposite, they will attract each other like the positive and negative poles of a magnet.
Lets take the ionic formula for Calcium Chloride is #CaCl_2#
Calcium is an Alkaline Earth Metal in the second column of the periodic table. This means that calcium has 2 valence electrons it readily gives away in order to seek the stability of the octet. This makes calcium a #Ca^(+2)# cation.
Chlorine is a Halogen in the 17th column or p5 group.
Chlorine has 7 valence electrons. It needs one electron to make it stable at 8 electrons in its valence shells. This makes chlorine a #Cl^(−1)# anion.
Ionic bonds form when the charges between the metal cation and non-metal anion are equal and opposite. This means that two #Cl^(−1)# anions will balance with one #Ca^(+2)# cation.
This makes the formula for calcium chloride, #CaCl_2#.
Molecular bonds are created when two or more non-metal atoms share valence electrons in order to complete the s and p orbitals of the highest energy level in order to complete the rule of octet.
Phosphorus #s^2 p^3# has a 5 valence electrons and needs three more to complete the rule of octet. Chlorine #s^2 p^5# has 7 valence electrons and needs one to complete the rule of octet.
Three Chlorine atoms will each share the unpaired electrons with the three unshared electrons on the Phosphorus. The resulting shared electron bonds form a compound of Phosphorus trichloride or #PCl_3#.
Ionic compounds will dissociate in solution forming electrolytes which become conductors of electricity, while covalent compounds do not dissociate remaining intact when they dissolve.
I hope this was helpful.