Below is the most commonly used function on my site, its used hundreds of times per minute probably thousands, Just curious if it could be improved to perform even better?
// show user photo
function show_user_photo($user_id,$photo_type='big',$user_name='yes',$online='yes'){
$LOCALIP=$_SERVER['REMOTE_ADDR'];
$sql_check="select * from friend_reg_user where auto_id='$user_id'";
$result_check=executeQuery($sql_check);
if($line_check=mysql_fetch_array($result_check)){
// checking for user exist
$sql_photo="select * from friend_user_photo where userid='$user_id' and defaultphoto='yes' order by auto_id desc";
$result_photo=executeQuery($sql_photo);
$pic1=''; $pic=''; $file='';
if($photo_type=='big'){
$noimg='nopic.gif';
} else {
$noimg='noimagesmall.jpg';
}
if($line_photo=mysql_fetch_array($result_photo)){
$file="uploded_files/userphoto/".$line_photo['photo_name'];
if($line_photo['photo_name']!='' && file_exists($file)){
$fil_ext1 = pathinfo($file);
$fil_ext = $fil_ext1["extension"];
$fil_explode='.'.$fil_ext;
$arr=explode($fil_explode,$line_photo['photo_name']);
if($photo_type=='big'){
$pic1=$arr[0]."_thumb".$fil_explode;
$height=130;
$width=160;
} else {
$pic1=$arr[0]."_thumb1".$fil_explode;
$height=80;
$width=90;
}
if(file_exists("uploded_files/userphoto/".$pic1)){
$img_name=$pic1;
} else {
$img_name=$noimg;
} } else {
$img_name=$noimg;
} } else {
$img_name=$noimg;
}
echo "<div style='height:$height;width:$width; overflow:hidden' align='center'><a href='index.php?action=memberprofile&type=common&userid=$user_id&unid=$_GET[unid]'><img src='uploded_files/userphoto/$img_name' border=0></a></div>";
if($user_name=='yes'){
$sql="select disp_name from friend_reg_user where auto_id='$user_id'";
$name=getSingleResult($sql);
echo "<div align='center' class='boldblue' valign='middle'>";
if(check_online_status($user_id,$LOCALIP) && $online=='yes'){
echo "<img src='images/online.gif' >"; } echo $name;
echo "</div>";
} else {
if(check_online_status($user_id,$LOCALIP) && $online=='yes'){
echo "<div align='center' class='boldblue' valign='middle'><img src='images/online.gif' ></div>";
}
}
} else {
if($photo_type=='big'){ $noimg='noexist.jpg'; }
else { $noimg='noexist1.jpg'; }
echo "<div style='height:$height;width:$width; overflow:hidden' align='center'><img src='uploded_files/userphoto/$noimg' border=0></div>";
}