Page 1 of 1

Avatar - Display

Posted: Thu Jul 12, 2012 2:40 am
by Ghoz
Hi,
I'm trying to modify the script to display avatars. I'm not familiar with php.
Please help. Thanks!

Code: Select all

<?php 
// This will allow to use the css inside includes if editing this file directly... probably
$visitingfiledirectly = false;
if($visitingfiledirectly)
{
	?>
    <link rel="stylesheet" type="text/css" media="screen" href="../stylus.css">
    <?php
}

?>
<b>Search Result:</b><br />
<div class="searchlist">
<?php
$uname = "";
if(isset($_POST["u"]) && !empty($_POST["u"]) && strlen($_POST["u"]) > 0)
{
	$uname = PHP_slashes($_POST["u"]);
}
						$result2 = mysql_query("SELECT Avatar, Username, LastLoginDate, Email FROM users where Username Like '%".$uname."%'");
						
if(mysql_num_rows($result2) > 0)
{
						?>
<table border = "1" width="100%">
<tr>
<td></td> 
<td><b>Username</b></td>
<?php
	if($admin >= 1)
	{
		?>
		<td><b>Email Address</b></td>
		<?php
	}				
?>
<td><b>Last Login</b></td>
</tr>
                        <?php

while ($row2 = mysql_fetch_row($result2)){
?>
<tr>
<td><?php useLightbox($result2[0],$result2[1],50,50);?></td> 
<td><a href="index.php?section=profile&uid=<?php echo getUserId($row2[1]);?>"><b><?php echo $row2[1];?></b></a></td>
<?php
if($admin >= 1)
	{
		?><td><?php echo $row2[3];?></td><?php
	}	
?><td><?php echo referencialHour($row2[2]);?></td> 
</tr><?php
  }
  
?>
</table>
</div>
<?php
}
else
{
?>
No users found
<?php
}

?>

Re: Avatar - Display

Posted: Thu Jul 12, 2012 6:04 am
by social_experiment
what does the code for useLightbox() look like

Code: Select all

 <td><?php useLightbox($result2[0],$result2[1],50,50);?></td> 

Re: Avatar - Display

Posted: Thu Jul 12, 2012 8:59 am
by Ghoz
Hi, what do you mean?

Anyway you could use the below script for comparison. The below script is taken from another php file. This script is able to display avatars, not like the previous script. This script is just for comparison only to see why the previous script is unable to display avatars. Thanks!

Code: Select all

<?php 
// This will allow to use the css inside includes if editing this file directly... probably
$visitingfiledirectly = false;
if($visitingfiledirectly)
{
	?>
    <link rel="stylesheet" type="text/css" media="screen" href="../stylus.css">
    <?php
}
?>
<?php 
$admin = getMyAdminLevel();
if($admin >= 1)
{
?>
<h1>Admin Users</h1>
<span class="manageusers">
<form method="POST" action="index.php?section=manageuser" id="smform">
<b>Search for user:</b>
<input type="text" size=30 name="u" /> <input type="submit" value="Search" id="sm" />
</form>
</span>
<br />
<div class="searchlist">
<?php 
$admin = getMyAdminLevel();
if($admin >= 1)
{
if(isset($_POST["ban"]) && is_numeric($_POST["ban"]) && isset($_POST["uid"]) && is_numeric($_POST["uid"]) && $_POST["uid"] != getUserId($_SESSION["username"]))
{
	$checkuser = mysql_query("SELECT Admin FROM users WHERE Id='".$_POST["uid"]."'"); // FIND THE DESIRED USER BY ID
	$user = mysql_fetch_array($checkuser); // COLLECT HIS DATA INTO AN ARRAY
	
	$admin = getMyAdminLevel();
	if($admin >= 1 && $_POST["ban"] >= 0 && $_POST["ban"] <= 1 && $user["Admin"] < $admin)
	{
	$query = 'UPDATE users SET Banned="'.$_POST["ban"].'" WHERE Id="'.$_POST["uid"].'"';
    mysql_query($query) or die(mysql_error()); // SET USER AS VALIDATED
	}
}
$uname = "";
if(isset($_POST["u"]) && !empty($_POST["u"]) && strlen($_POST["u"]) > 0)
{
	$uname = PHP_slashes($_POST["u"]);
}
						$result = mysql_query("SELECT Id FROM users WHERE Username LIKE '%".$uname."%'");
// Fill up array with names
	$row = mysql_fetch_array($result);
if($row > 0)
{
	$result = mysql_query("SELECT Id, Banned, Admin, Avatar, Username, LastLoginDate, Email FROM users WHERE Username LIKE '%".$uname."%'");
	?><table>
	<tr>
	<td>Img</td>
	<td>Username</td>
	<td>Email</td>
	<td>Action</td>
	<td>LastLogin</td>
	<td>Connect As</td>
	</tr><?php
	while($row = mysql_fetch_array($result))
	{
		?>
		<tr>
		<td><?php useLightbox($row["Avatar"],$row["Username"],30,30)?></td>
		<td><a href="index.php?section=profile&uid=<?php echo $row["Id"];?>"><?php echo $row["Username"];?></a></td>
		<td><?php echo $row["Email"];?></td>
		<td><?php
		if($row["Admin"] < $admin)
		{
	if($row["Banned"] == 0)
		{
		?><form method="POST" action="index.php?section=manageuser" id="smform">
			<input type="hidden" name="u" value="<?php if(isset($_POST["u"]))echo $_POST["u"];?>"/><input type="hidden" name="uid" value="<?php echo $row["Id"];?>"/><input type="hidden" name="ban" value="1"/><input type="submit" value="Ban" id="sm">
			</form><?php
		}
		else
		{
			?>
		<form method="POST" action="index.php?section=manageuser" id="smform">
			<input type="hidden" name="u" value="<?php if(isset($_POST["u"]))echo $_POST["u"];?>"/><input type="hidden" name="uid" value="<?php echo $row["Id"];?>"/><input type="hidden" name="ban" value="0"/><input type="submit" value="Unban" id="sm">
			</form><?php
		}
		}
		?></td>
		<td><?php echo referencialHour($row["LastLoginDate"]);?></td>
		<td><a href="connectas.php?uid=<?php echo $row["Id"];?>"><?php echo $row["Username"];?></a></td><?php
	}
	?></table><?php
}
else
{
	?>No users found<?php
}
}
?>
</div>
<?php
}
else
{
	?><div class="warning">Still under construction...</div><?php
}
?>

Re: Avatar - Display

Posted: Thu Jul 12, 2012 4:26 pm
by social_experiment

Code: Select all

<?php
while ($row2 = mysql_fetch_row($result2)){
?>
<tr>
 // you want to access $row2, it will contain the information from the 
 // resource contained in $result2
<td><?php useLightbox($result2[0],$result2[1],50,50);?></td> 
?>
You want to use $row2 here instead of $result2; to access the values in $row2 you need to use $row2[0] which will contain the avatar details;

Code: Select all

 // should be
<td><?php useLightbox($row2[0],$row2[1],50,50);?></td> 

Re: Avatar - Display

Posted: Thu Jul 12, 2012 8:55 pm
by Ghoz
Hi,
Thanks!!! It works.
Just replace $result2 with $row2
You are wonderful!!!
:D

Re: Avatar - Display

Posted: Sat Jul 21, 2012 1:17 am
by Ghoz
Topic closed