Page 1 of 1
Limit characters
Posted: Wed Mar 16, 2005 10:22 pm
by Jim_Bo
Hi,
How do you limit characters on just one of the fields within a loop ..?
Thanks
Posted: Wed Mar 16, 2005 10:26 pm
by feyd
huh?

Posted: Wed Mar 16, 2005 10:41 pm
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 ..
re
Posted: Wed Mar 16, 2005 10:56 pm
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
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Posted: Wed Mar 16, 2005 11:17 pm
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 ..
Posted: Wed Mar 16, 2005 11:20 pm
by feyd
substr()
and there's a post about some other fun with this in the "Useful Posts" thread.

Posted: Wed Mar 16, 2005 11:44 pm
by Jim_Bo
Hi,
Great thanks for that .. got is sorted ..
Cheers