Jump to content

Archived

This topic is now archived and is closed to further replies.

fullyloaded

site error

Recommended Posts

hi
i have a small problem on my sites home page i have a dating website with 3 newest members on the front page my problem is when the 3 newest members usernames are to long it will split my image apart is there anyway you can fix this so if there username is long it will only show part of there username and not split the image on the site? here is the site you can see the problem there on the main page [url=http://www.singlespleasures.com]http://www.singlespleasures.com[/url] thanks...

Share this post


Link to post
Share on other sites
Hi,

you can use [url=http://www.php.net/manual/en/function.substr.php]substr[/url] function:

string substr ( string string, int start [, int length] )

And of you want to show only a part of the user name you can make like this:

$username = substr($username, 1, 15);

Hope this is what you ment.

Share this post


Link to post
Share on other sites
hi dymon
thanks can you tell me where to put this code? $username = substr($username, 1, 15); here is the code for the main page of my site the usernames would be this in the code "NM_NAME"    =>        $dbu->f('username'),[code]<?php


$dbu=new mysql_db;

$ft=new ft(ADMIN_PATH.MODULE."templates/");
$ft->define(array('main' => "home.html"));
$ft->define_dynamic('member_row','main');

//*************Quick Search Form***********************
if($_SESSION['photo'])
{
$checked='checked';
}

if($_SESSION['st_online'])
{
$checked2='checked';
}

$ft->assign(array(
                  "COUNTRY"        =>        build_country_list($_SESSION['country']),
                  "S_G"            =>        build_gender_list($_SESSION['s_g']),
                  "SSY" =>   build_numbers_list(LOWEST_AGE, HIGHEST_AGE,$_SESSION['ssy']),
                  "ESY"  =>   build_numbers_list(LOWEST_AGE, HIGHEST_AGE,$_SESSION['esy']),
                  "CHECKED"  =>   $checked,
                  "CHECKED2"  =>   $checked2,
                )
);

$dbu->query('SELECT COUNT(*) AS rowcount FROM member');
    $dbu->move_next();
    $ft->assign('MEMBER', $dbu->f('rowcount'));
   
$ft->assign("V_NO", $i);

    $time_stamp = mktime ( date("H"), date("i")-ONLINE_TIMEOUT, date("s"), date("m"), date("d"), date("Y") );
   
$dbu->query("SELECT COUNT(*) AS maxrows FROM member WHERE action >= '".$time_stamp."'");
$dbu->move_next();
$ft->assign("ONLINE_NO", $dbu->f('maxrows') );
//****************Fast Facts***************************
$dbu->query("select count(member_id) as num_rec from member where active1='1' AND active2='1' AND visible='2'");
$dbu->move_next();
$total_profiles=$dbu->f('num_rec');

$dbu->query("select count(member_id) as num_rec from member where gender = 'Man' AND active1='1' AND active2='1' AND visible='2'");
$dbu->move_next();
$man_profiles=$dbu->f('num_rec');

$dbu->query("select count(member_id) as num_rec from member where gender = 'Woman' AND active1='1' AND active2='1' AND visible='2'");
$dbu->move_next();
$woman_profiles=$dbu->f('num_rec');
$ft->assign(array(
                  "TOTAL_PROFILES"    =>        $total_profiles,
                  "MEN_PROFILES"    =>        number_format((( $man_profiles * 100 ) / $total_profiles )),
                  "WOMEN_PROFILES"    =>        number_format((( $woman_profiles * 100 ) / $total_profiles )),
                )
          );


//*********get most viewed man*****************
$dbu->query("select username, member_id, birthdate, picture, thumb, country from member where gender = 'Man' order by viewed DESC limit 0,2");
$dbu->move_next();
list($b_year,$b_month,$b_day )=split("-",$dbu->f('birthdate'));
$ft->assign(array(
                  "MP_MAN_NAME"    =>        $dbu->f('username'),
                  "MP_MAN_LOCATION"    =>        $dbu->f('country'),
                  "MP_MAN_AGE"    =>        get_age($b_month,$b_day,$b_year),
                  "MP_MAN_VIEW"    =>        'member/index.php?pag=member_profile&member_id='.$dbu->f('member_id'),
                )
          );
if($dbu->f('thumb'))
{
$ft->assign('MP_MAN_IMAGE', $script_path.UPLOAD_PATH.$dbu->f('thumb'));
}
else
{
$ft->assign('MP_MAN_IMAGE', $script_path.'img/na_small.gif');
}

//*********get most viewed woman*****************
$dbu->query("select username, member_id, birthdate, picture, thumb, country from member where gender = 'Woman' order by viewed DESC limit 0,2");
$dbu->move_next();
list($b_year,$b_month,$b_day )=split("-",$dbu->f('birthdate'));
$ft->assign(array(
                  "MP_WOMAN_NAME"    =>        $dbu->f('username'),
                  "MP_WOMAN_LOCATION"    =>        $dbu->f('country'),
                  "MP_WOMAN_AGE"    =>        get_age($b_month,$b_day,$b_year),
                  "MP_WOMAN_VIEW"    =>        'member/index.php?pag=member_profile&member_id='.$dbu->f('member_id'),
                )
          );
if($dbu->f('thumb'))
{
$ft->assign('MP_WOMAN_IMAGE', $script_path.UPLOAD_PATH.$dbu->f('thumb'));
}
else
{
$ft->assign('MP_WOMAN_IMAGE', $script_path.'img/na_small.gif');
}

//*******get newest members*********************************
$dbu->query("SELECT member_id, username, birthdate, picture, thumb, gender FROM member WHERE active1='1' AND active2='1' AND visible='2' ORDER BY member_id DESC LIMIT 3");
while($dbu->move_next())
{
list($b_year,$b_month,$b_day )=split("-",$dbu->f('birthdate'));
$ft->assign(array(
                  "NM_NAME"    =>        $dbu->f('username'),
                  "NM_GENDER"    =>        $dbu->f('gender'),
                  "NM_AGE"    =>        get_age($b_month,$b_day,$b_year),
                  "NM_VIEW"    =>        'member/index.php?pag=member_profile&member_id='.$dbu->f('member_id'),
                )
          );
if($dbu->f('thumb'))
{
$ft->assign('NM_IMAGE', $script_path.UPLOAD_PATH.$dbu->f('thumb'));
}
else
{
$ft->assign('NM_IMAGE', $script_path.'img/na_small.gif');
}
         
$ft->parse('member_ROW_OUT','.member_row');       
}


$ft->assign('MESSAGE',$glob['error']);

$ft->parse('CONTENT','main');
//$ft->fastprint('CONTENT');
return $ft->fetch('CONTENT');

?>[/code]

Share this post


Link to post
Share on other sites
$ft->assign(array(
                  "NM_NAME"     =>        [b]substr(1, 15, $dbu->f('username'))[/b],
                  "NM_GENDER"     =>        $dbu->f('gender'),
                  "NM_AGE"      =>        get_age($b_month,$b_day,$b_year),
                  "NM_VIEW"      =>        'member/index.php?pag=member_profile&member_id='.$dbu->f('member_id'),
                 )
           );

This should work ok.
Otherwise you can make this change in the HTML output, this should be in the [b]$dbu[/b] or in [b]$ft[/b] object.

Share this post


Link to post
Share on other sites
Hi,

sorry I made a small mistake in usage of the function:

"NM_NAME"    =>        substr($dbu->f('username'), 0, 15),

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.