You want to solve for y (I'll use x as the symbol for multiplication) :
ay = b (mod c)
where a, b and c are 3 given integers.
First, you must find the largest common divisor between a and c (let's say d).
In your example,
a = 15
b = 51
c = 117
d = 3
If d is not a divisor of b, then the equation has no (integer) solution. A proof is easy : b = ay + kc (with k some integer), so if d divides both a and c, he also divides ay + kc, hence b.
Else, you must divide by d all the 3 coefficients. So you can assume, from now, that a and c have no higher common divisor than 1.
In your example, the new equation is : 5y = 17 (mod 39)
where a = 5, b = 17 and c = 39.
Next, you must find 2 integers u and v for which : au + cv = 1.
Those integers are the Bezout coefficients, you can find them thanks to Euclid's algorithm. See below if you need.
The fact that a and c have no common divisor assure you that u and v exist (they are not unique, but it doesn't matter).
In you example : 5x8 + 39x(-1) = 40 - 39 = 1 so you can take u = 8 and v = -1.
Now multiply the last equation by b :
aub + cvb = b
au' + cv' = b
where u' and v' are 2 new integers (u' = 8x17 = 136 and v' = (-1)x17 = -17 )
Last, you can substract :
ay = b (mod c)
au' = b (mod c)
leading to : a(y - u') = 0 (mod c)
and since a and c have no common divisor, this assure you that y - u' = 0 (mod c), in other words : y = u' + kc (with k some integer).
Conclusion :
ay = b (mod c) if and only if y = u' (mod c)
Remember that all common divisors between a and c must be eliminated first.
In your example :
15y = 51 (mod 117) if and only if y = 136 (mod 39), or y = 19 (mod 39), since 136 = 19 (mod 39)
Back to Euclid's algorithm : use it to find the largest common divisor between 2 integers, start with the highest of the 2 (example with 39 and 5) :
39 = 7x5 + 4
5 = 1x4 + 1
the last non-zero rest is 1 (ie : 1 is the highest common divisor between 39 and 5).
Now start from 1 :
1 = 5 - 1x4
and since 4 = 39 - 7x5 (previous line),
1 = 5 - 1x(39 - 7x5)
1 = 5 - 1x39 + 7x5
1 = (1+7)x5 - 1x39
1 = 8x5 - 1x39
Of course, you could find immediatly 8 and -1 in this case. But this algorithm helps for higher numbers (or if you want to create a computer program).
Feel free to pm if something is missing, good luck.