//function that takes username and avatar
function take_username_avatar()
{
try{
$results = array();
$query = mysql_query("SELECT username,avatar FROM data WHERE username!='{$_SESSION['username']}'")or die(mysql_error());
while($row = mysql_fetch_assoc($query))
{
$results[] = $row;
}
return $results;
}
catch (Exception $e){
die("Error showing user list");
}
}
//page that shows user list
$username_avatar = take_username_avatar();
foreach ($username_avatar as $user_avatar ) {
?>
<p><a href='index.php?page=profile& username =<?php echo $user_avatar [' username ']; ?>'>
<?php echo $kor_avatar[' username '] ?></a></p>
<a href='index.php?page=profile&username=<?php echo $ user_avatar ['username']; ?>'>
<img src="avatar/<?php echo $kor_avatar['avatar']; ?>" height='100' width='100' alt='avatar'></a>
<?php
}
I have been trying to solve this for some time, even too long and I would really appreciate the help of experienced PHP user.
I have made that user can see the list of the other members on the website but I also want to show error message if something goes wrong.
I did it with try-catch block but I also been wondering if there is an efficient way to do that.
I would also like to know how to make the error to happen because I need to make a print screen for documentation.