-
Notifications
You must be signed in to change notification settings - Fork 0
/
function.php
41 lines (32 loc) · 942 Bytes
/
function.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
//function.php
function make_avatar($character)
{
$path = "avatar/". time() . ".png";
$image = imagecreate(200, 200);
$red = rand(0, 255);
$green = rand(0, 255);
$blue = rand(0, 255);
imagecolorallocate($image, $red, $green, $blue);
$textcolor = imagecolorallocate($image, 255,255,255);
imagettftext($image, 100, 0, 55, 150, $textcolor, 'font/arial.ttf', $character);
//header("Content-type: image/png");
imagepng($image, $path);
imagedestroy($image);
return $path;
}
function Get_user_avatar($user_id, $connect)
{
$query = "
SELECT user_avatar FROM register_user
WHERE register_user_id = '".$user_id."'
";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
foreach($result as $row)
{
echo '<img src="'.$row["user_avatar"].'" width="75" class="img-thumbnail img-circle" />';
}
}
?>