Below is my function which will get
- a users image
- a users name
- a users online status
Some of my quiries already pull in a users name so instead of and extra query for name is there a way to pass the name from my page into this function when I call it
here is how I call it now
<?
show_user_photo($line['auto_id'],$photo_type='small',$user_name='yes')
//could I do something like this
show_user_photo($line['auto_id'],$photo_type='small',$user_nameSET='JasonDavis')
?>
function show_user_photo($user_id, $photo_type = 'big', $user_name = 'yes', $online = 'yes') {
$LOCALIP = $_SERVER['REMOTE_ADDR'];
$sql_check = "select auto_id 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 photo_name 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 align='center'><a href='?p=profile&userid=$user_id'><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'>";
$trunc_name = preg_replace("/(\S{15,}?)/", "$1<br />", $name);
echo $trunc_name;
if (check_online_status($user_id, $LOCALIP) && $online == 'yes') {
echo "<BR><img src='images/online.gif' >";
}
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>";
}
}