You're generating a random password, then you're running one query to set every password to that random password, so they will all be the same. What you need is a query to select every record, get each row, generate the random password individually for each row, then assign it to the password. So roughly pseudo-code:
$result = mysql_query("select * from ques_ans_data")
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)
$pw = rand()
$res = mysql_query("update ques_ans_data set rec_restriction=$pw where id = <your-record-id>")
So you grab each record in turn, generate the password, then post it back into the record, then loop to the next record.