sammry -3 Light Poster

Hi,

I am trying to give an avatar to my visitors based on their sex and their profile pic.i have written a code and am getting the desired result, but not happy with the coding part, hence seeking help on this.

My member database contains, profilepicture field where member can upload their picture and second filed is gender where they can select their gender after verifying their registration.

I have the following function code which does the job.

function mempropic($var)
{
        global $datconn;
        $query="SELECT ppic, ugender FROM reg_members WHERE user_id='".mysql_real_escape_string($var[user_id])."' limit 1";
        $executequery=$datconn->execute($query);
		$results = $executequery->fields[ppic];
		$results1 = $executequery->fields[ugender];
		if ($results != "")
			return $results;
		elseif ($results1 == "Male")
			return "mavatar.gif";
		elseif ($results1 == "Female")
			return "favatar.gif";
		else ($results == "")
			return "nopic.gif";
		else
			return $results;
}

I am still learning the coding part, so please help