Web Hosting Vodahost    

Home Take The Royal Tour! Order Now Features Prices
Go Back   Web Hosting > VodaHost Web Hosting Support > mySQL & PHP

Notices

mySQL & PHP Discussions, information and help with mySQL and PHP.

Reply
 
LinkBack Thread Tools
  #1  
Old 03-20-2008, 02:30 PM
Second Lieutenant
 
Join Date: Feb 2008
Posts: 123
Default Adding to php code

Hello
i have part of a PHP code that prints on the screen something from my DATABASE
echo $row['posting_discription'];

i wanted to know if i can add something to this line of code to make the posting discription (usualy more then 20 words) to show only 4-6 words and "..." after and it will show as a link to another page(or even the same one) with the full posting ( like in www.craigslist.com)

thanks alot
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old 03-20-2008, 03:29 PM
Second Lieutenant
 
Join Date: Feb 2008
Posts: 123
Default Re: Adding to php code

more...
can i actialy create a design via PHP code
how i can add something after the echo that will add color for text and stuff?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old 03-20-2008, 08:13 PM
Watdaflip's Avatar
Brigadier General
 
Join Date: Sep 2005
Location: Cincinnati, Ohio
Posts: 1,638
Default Re: Adding to php code

The easier way is to cut it off after a character limit, to do that do something like..

PHP Code:
$max_char 50;
if(
strlen($row['posting_discription']) >= $max_char)
{
$row['posting_discription'] = substr($row['posting_discription'], 0$max_char)."...";

That will cut it off at 50 characters and add ... to the end.

As far as formatting the color, you just add html to the strings... like
PHP Code:
$sometext "<span style=\"color: #FF0000\">Red text</span>"
__________________

Register/Login Script
Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 04:04 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC7
2007 VodaHost.com - All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55