Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

limit characters displayed from dbase field 1

Status
Not open for further replies.

darryncooke

Technical User
May 6, 2009
308
US
This is a script I found online and it works for static text but not for text that I am trying to pull from a dbase.

<?
$position=8; // Define how many characters you want to display.

$message=echo $row_articles_select['title'];
$post = substr($message,$position,1); // Find what is the last character displaying. We find it by getting only last one character from your display message.

if($post !=" "){ // In this step, if last character is not " "(space) do this step .

// Find until we found that last character is " "(space)
// by $position+1 (14+1=15, 15+1=16 until we found " "(space) that mean character 20)
while($post !=" "){
$i=1;
$position=$position+$i;

$message=echo $row_articles_select['title'];
$post = substr($message,$position,1);
}

}

$post = substr($message,0,$position); // Display your message
echo $post;
echo "...";
?>

Any idea why it isnt working?

Darryn Cooke
| The New Orange County Graphic designer and Marketing and Advertising Consultant
| Marketing and Advertising blog
 
Remove the echo from
$message=echo $row_articles_select['title'];

Both places.

Mark
 
most helpful.

You know I was thinking about defining the variable first but I guess thats been taken care of and echo is to output to the page so I was using it wrong.

thank you,

Darryn Cooke
| The New Orange County Graphic designer and Marketing and Advertising Consultant
| Marketing and Advertising blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top