displaying a limit number of rows from a text field
Moderator: General Moderators
- pelegk2
- Forum Regular
- Posts: 633
- Joined: Thu Nov 27, 2003 5:02 am
- Location: Israel - the best place to live in after heaven
- Contact:
displaying a limit number of rows from a text field
i have a text field which hold's a text written by user
and i wantto do a preview while will show for each user only the first 3 row's.
how can i do that?
thnaks in advance
peleg
and i wantto do a preview while will show for each user only the first 3 row's.
how can i do that?
thnaks in advance
peleg
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
Code: Select all
$lines = explode("\n",$textarea_contents);
echo "Preview : " . $linesї0] . $linesї1] . $linesї2];or
You could use the substr() function to call the first 100 characters or so from the entries.
It'd look like this.
It'd look like this.
Code: Select all
$preview = substr($entry, 0, 100);
echo $preview;- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
I think calling a certain amount of characters would be more effective, as it would imply that there is more text available and this is only a preview.
with the word being cut off and "..." being displayed it would imply there is more text to be read.
If you just display a certain number of words the user might think, "well, hrmm, that's it?"
Code: Select all
$preview = substr($entry, 0 , 100);
echo "$preview...";If you just display a certain number of words the user might think, "well, hrmm, that's it?"
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
- pelegk2
- Forum Regular
- Posts: 633
- Joined: Thu Nov 27, 2003 5:02 am
- Location: Israel - the best place to live in after heaven
- Contact:
how can you do a word count with regEx?
thnaks
Peleg
Peleg
this is a nice query trick for mysql i once found 
Code: Select all
SELECT SUBSTRING_INDEX(content,' ',20) as description
FROM message