Limit username length in this block?

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Limit username length in this block?
Browser
CZ Super Newbie
 Codezwiz Site Donator
Browser has been a member for over 19 year's 19 Year Member
Status: Offline
Joined: Nov 14, 2004
0.01 posts per day
Posts: 48
Points: 5,631
   
Can someone please help me with this block code? I want to truncate or limit the length of long usernames that push my block out of size. Here are the lines of code I am currently using:

$lasturow = $db->sql_fetchrow($db->sql_query("SELECT username FROM $user_prefix"._users." ORDER BY user_id DESC LIMIT 0,1"));
$lastuser = $lasturow['username'];
$numrows = $db->sql_numrows($db->sql_query("SELECT user_id FROM $user_prefix"._users.""));

$result = $db->sql_query("SELECT uname, guest FROM $prefix"._session." WHERE guest='0'");
$member_online_num = $db->sql_numrows($result);
$who_online_now = "";
$i = 1;
while ($session = $db->sql_fetchrow($result)) {
    if (isset($session["guest"]) and $session["guest"] == 0) {
        if ($i < 10) {
            $who_online_now .= " ;; ;;0$i: ;;$session[uname]<br>\n";
        } else {
            $who_online_now .= " ;; ;;$i: ;;$session[uname]<br>\n";
        }
        $who_online_now .= ($i != $member_online_num ? "  " : "");
        $i++;
    }
}



Back to top Reply with quote
#2   re: Limit username length in this block?
fncool
CZ Super Newbie
 Codezwiz Site Donator
fncool has been a member for over 19 year's 19 Year Member
canada.gif
Age: 62
Gender: Male
Status: Offline
Joined: Dec 19, 2004
0.01 posts per day
Posts: 56
Points: 4,786
   
that looks like the wrong code

open modules/Your_Account/index.php
search for instances of:
maxlength=\"25\"

and replace the 25 with the number you like

i suggest 16
be careful if you have registered users with longer names already, they may not be able to log in after.
there are a few instances, likely, one is a couple lines after this bit:
"_REGNEWUSER" thats the signup one, which is likely the one you care about.
if you already have users with longer names, i guess you could email them, or warn them that you will be changing their name, then you can edit their account and do any other instances.

if you just want it to display the first 16 chars of the name, no matter how long, then i'm not sure, and i'm totally wasting my time replying!

lol



_________________
I'm only replying because I want those extra 22.52 points!
Back to top Reply with quote
#3   re: Limit username length in this block?
gotcha
CZ Newbie
 Codezwiz Site Donator
gotcha has been a member for over 19 year's 19 Year Member
usa.gif
Gender: Male
Website:
Status: Offline
Joined: Feb 22, 2005
0.00 posts per day
Posts: 11
Points: 1,117
   
$output = substr($input, 0, 16)

of course change $input to the value you want to trim down and 16 to the # of characters you want to display.


Back to top Reply with quote
#4   Re: re: Limit username length in this block?
Browser
CZ Super Newbie
 Codezwiz Site Donator
Browser has been a member for over 19 year's 19 Year Member
Status: Offline
Joined: Nov 14, 2004
0.01 posts per day
Posts: 48
Points: 5,631
   
Thanks for the replies. I have already limited the new user registrations after I discovered the problem with this template block width. I do not want to ask all the users to modify their usernames unless there is no other option.

Regarding the reply below, where do I add this in the code? I tried a few places but must be doing it wrong.



Originally posted by gotcha @ Tue Feb 22, 2005 4:54 pm:

$output = substr($input, 0, 16)

of course change $input to the value you want to trim down and 16 to the # of characters you want to display.


Thank you for the assistance!


Back to top Reply with quote
#5   re: Limit username length in this block?
gotcha
CZ Newbie
 Codezwiz Site Donator
gotcha has been a member for over 19 year's 19 Year Member
usa.gif
Gender: Male
Website:
Status: Offline
Joined: Feb 22, 2005
0.00 posts per day
Posts: 11
Points: 1,117
   

$lasturow = $db->sql_fetchrow($db->sql_query("SELECT username FROM $user_prefix"._users." ORDER BY user_id DESC LIMIT 0,1"));
$lastuser = $lasturow['username'];
$numrows = $db->sql_numrows($db->sql_query("SELECT user_id FROM $user_prefix"._users.""));

$result = $db->sql_query("SELECT uname, guest FROM $prefix"._session." WHERE guest='0'");
$member_online_num = $db->sql_numrows($result);
$who_online_now = "";
$i = 1;
while ($session = $db->sql_fetchrow($result)) {
    if (isset($session["guest"]) and $session["guest"] == 0) {
        if ($i < 10) {
            $who_online_now .= "0$i:".substr("$session[uname]", 0, 16)."<br>\n";
        } else {
            $who_online_now .= " $i:".substr("$session[uname]", 0, 16)."<br>\n";
        }
        $who_online_now .= ($i != $member_online_num ? "  " : "");
        $i++;
    }
}


Try that out.


Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum