Limit characters

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Limit characters

Post by Jim_Bo »

Hi,

How do you limit characters on just one of the fields within a loop ..?


Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

huh? :?
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

Kinda thought I was gunna get a reply like that .. soz

.. I have an admin panel to update news etc .. When the data is called back its in an alternating colour row format .. there are 3 fields been displayed back from the database " id, date, description" ..

What I want to do is limit the amount of characters that get displayed within the description field to say 50 characters .. as it is only a preview pane with a link off to edit | delete record .. Basically its so the rows dont end up to big as some of the descriptions hold alot of characters ..

Hopefully that makes better sence ..


Thanks ..
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

re

Post by harrisonad »

supposing that you have a class named "Field", and an array of it's instance named $fields_aray....

Code: Select all

//-------------------------
foreach($fields_aray as $field){
    if($field->setType()==TYPE_TEXTBOX)
        $field->setSize(50);
    else
        $field->setSize(DEFAULT_SIZE);
    $field->showInputBox();
}
//----------------------------
if that's not what you're trying to ask, just forget about it, OK?


feyd | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

Is that to display it back in a text area or just a table?

I am wanting the limit with data displayed within a table .. then the edit link moves onto the textarea with no limit on the characters ..


Thanks ..
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

substr()

and there's a post about some other fun with this in the "Useful Posts" thread. :?
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

Great thanks for that .. got is sorted ..


Cheers
Post Reply