Freddie Bingham
Mon 17th Jul '00, 2:41am
I want an image that corresponds to a particular user to be displayed in $fivelinks
What is the most effecient way to make this call? Right now I have the SQL code in global.php before the call to the fivelinks template. This gets the path for the user's image, puts it in a variable and that variable is in the $fivelinks template. It seems to me that this call will be made with every page that includes global.php. Is this the best way to do it or is there a way to only make this call once and have the image path remembered through the session?
I tried putting an "isset" before it but I don't know the scope of variables in PHP and whether it "remembers" variables from one call on the file to another. It seemed to think it was never set when I hit refresh so I suppose it doesn't.
This is the code I have in global.php and I am just afraid it will get called more times than it possibly may need to be.
// Avatar Hack Begin
if ($bbuserid != 0)
{
$avatars = $DB_site->query("SELECT avatar.iconname " .
"from avatar, user WHERE avatar.iconid = user.iconid ".
"and user.userid = $bbuserid");
$avatar = $DB_site->fetch_array($avatars);
$usericon = $avatar["iconname"];
$usericon = "<img src=\"$usericon\" align=\"middle\" border=\"0\">";
}
else
{
$usericon = "<img src=\"avatar/anon.gif\" align=\"middle\" border=\"0\">";
}
// Avatar Hack End
eval("\$fivelinks = \"".gettemplate("fivelinks")."\";");
It is so the user will see their UserIcon beside the links in $fivelinks. On a another note is there anyway to place that code *below* fivelinks and still have fivelinks recognize the $usericon variable. Do I need to make it a function and place a function declaration before $fivelinks as I would do in C?
[Edited by rangersfan on 07-17-2000 at 01:46 AM]
What is the most effecient way to make this call? Right now I have the SQL code in global.php before the call to the fivelinks template. This gets the path for the user's image, puts it in a variable and that variable is in the $fivelinks template. It seems to me that this call will be made with every page that includes global.php. Is this the best way to do it or is there a way to only make this call once and have the image path remembered through the session?
I tried putting an "isset" before it but I don't know the scope of variables in PHP and whether it "remembers" variables from one call on the file to another. It seemed to think it was never set when I hit refresh so I suppose it doesn't.
This is the code I have in global.php and I am just afraid it will get called more times than it possibly may need to be.
// Avatar Hack Begin
if ($bbuserid != 0)
{
$avatars = $DB_site->query("SELECT avatar.iconname " .
"from avatar, user WHERE avatar.iconid = user.iconid ".
"and user.userid = $bbuserid");
$avatar = $DB_site->fetch_array($avatars);
$usericon = $avatar["iconname"];
$usericon = "<img src=\"$usericon\" align=\"middle\" border=\"0\">";
}
else
{
$usericon = "<img src=\"avatar/anon.gif\" align=\"middle\" border=\"0\">";
}
// Avatar Hack End
eval("\$fivelinks = \"".gettemplate("fivelinks")."\";");
It is so the user will see their UserIcon beside the links in $fivelinks. On a another note is there anyway to place that code *below* fivelinks and still have fivelinks recognize the $usericon variable. Do I need to make it a function and place a function declaration before $fivelinks as I would do in C?
[Edited by rangersfan on 07-17-2000 at 01:46 AM]