Through the process of photosynthesis, producers like green plants, algae and certain bacteria can convert energy from sunlight into the chemical energy bonds of the organic compound glucose-- a monosaccharide, or simple sugar. This is an anabolic or energy storing process. Producers use the pigment chlorophyll to absorb the sunlight for this process to occur.
Since cells require energy to carry out life processes, they can utilize the chemical energy stored in organic molecules like glucose and use it to regenerate ATP, an energy currency molecule that cells use to carry out cellular work like growth, repair and reproduction. Through cellular respiration, the stored energy in glucose is released in controlled steps in what is known as a catabolic pathway. There is a great deal of potential energy stored in the bonds of glucose, due to the arrangement of the electrons that are located in the chemical bonds of the atoms inside glucose.
As respiration occurs, enzymes help to break down the glucose, thereby releasing energy to do work as well as some which is released as heat. In aerobic respiration which is a very efficient process, oxygen is used as a reactant to completely break down glucose into carbon dioxide and water as products, along with ATP. However, in photosynthesis, carbon dioxide and water are used as reactants along with sunlight to produce glucose and oxygen as products. In a sense, the two processes are opposite--photosynthesis stores energy and respiration releases it for cells to use. A less efficient type of respiration known as anaerobic respiration or fermentation, doesn't completely break down the sugar and the reaction occurs in the absence of oxygen. Far less ATP is produced by this process which occurs in certain bacteria and yeast.
When photosynthesis occurs, energy from the sun is used to split water into H+ ions and oxygen. The electrons are transferred with the hydrogen ions to carbon dioxide to reduce it to sugar. As these electrons move from the water, to the sugar, they gain energy provided by sunlight which is the opposite of what occurs in cellular respiration. In cellular respiration, energy is released from sugar because electrons from the H atoms are transported by carrier molecules to oxygen which forms water as a product at the end of photosynthesis.
In a simplified equation of photosynthesis which just shows water that is consumed, it
reads--6 C02 +6H20 + energy---> C6H1206+602
In words, six molecules of carbon dioxide plus 6 molecules of water plus energy from sunlight forms 1 molecule of glucose plus 6 molecules of oxygen. And, if you read it from right to left, it is actually the equation of cellular respiration where oxygen and glucose react together to produce the waste products carbon dioxide and water along with energy in the form of ATP.
I hope this clarifies how these two processes are different.