CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Label length

Print topic Send  topic

Author Message
RipCurl
Posted: 05/09/2003, 12:43 AM



CC php and templates Mysql


Is there a way to limit the number of characters/text displayed in a label? Im trying to develop a news section and just want part of the artcile to display, and hit a "more" link to get the rest of the article. Also the title of the article will link to the newsarticle as well.

news_id, articletitle, article, and date are my fields in my news table.

I know of CONCAT() for MySQL but have no idea on how to construct the query.

RipCurl
Posted: 05/09/2003, 3:29 PM

Thanks to support for the suggestion of substr() I was able to get the code to work


If anyone else is insterested, in running a similar grid for a news section, just create your grid as normal, add an extra URL field, name it ...read more or something to that effect, do not choose a row from your table list, in your field properties for that new url field, name it "more", default value = ...read more , data type = text , page link = whatever page you will display the entire article with (record form), HTML checked, and add parameters checked.

OUTPUT section, make the parameter equal to your key field (ie news_id=news_id).

In your BEFORE SHOW of the grid, add this code

$num_chars=300; // however much characters you want to show
$space=" ";
if(strlen($fldname) > $num_chars ) {
$fldname = substr(trim($fldname),0,$num_chars);
$fldname = substr($fldname,0,strlen($fldname)-strpos(strrev($fldname),$space));
$fldname = $fldname.'...';
}

replace $fldname with the field name of the text you are trying to "truncate".
des35
Posted: 10/03/2003, 6:40 PM

Is there an ASP version of this?

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.