Question: I'm asked to find force on square loop (side a) carrying current $I$, flowing counter clockwise, when we look down x-axis, lying in yz plane. the loop is centered at the origin. The magnetic field is given as:

$\vec{B} = kz\hat{x}$

Its solution states that force on left an right cancel each other .The force on top is $IaB=iak(a/2)$ pointing upward and the force on bottom is$IaB=-iak(a/2)$ also pointing upward .How the force on bottom is upward? (From where minus sign came?). By R.H.R it should be downward.

Answer: 
The minus is coming from the value of z. Note that the loop is *centered* at the origin on the *yz plane*, and the value of B is *dependent on the value of z*.

The forces on the left and right arms of the loop cancel out, the forces on the top and bottom arm are also opposite but due to the nature of the B field (dependence on z) the values are opposite in sign.

So one is $iak(a/2)$ in the $\hat z$ direction and the other is $iak(-a/2)$ in the $-\hat z$ direction. so when you add them together, instead of cancelling out you are left with double of the force.
first you take the direction of current vector and start turning /rotating screw from I towards the B vector ;if the rotation of the screw is clockwise screw movement will be perpendicular to the plane containing Current and Field vector and it will give you direction of the force .
 if the screw rotates anticlockwise it is coming out backwards this direction will be direction of the force- naturally on your rectangular frame the two arms carrying currents which are perpendicular/or making an angle with the B field will experience a couple providing a torque let us see if it works!
for those currents which are in the direction or opposed to magnetic field direction will not experience any forces as the vector product will vanish.