Forum Moderators: coopster

Message Too Old, No Replies

reduce the Combo box content

         

Madhu

10:58 am on Aug 2, 2007 (gmt 0)

10+ Year Member



Hi all
In my php & html page i placed a combo box.I will displays the content(colleges name) from the database .The names are too long. and the size of the allocated combo box is less.Now i have to display the names with starting 10 charecters in the page.

how can i do it?
Help Plzzzzzzzzzzz

Madhu

dreamcatcher

11:12 am on Aug 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Madhu,

$string = '123456789123456789123456789';

echo substr [uk.php.net]($string,0,10);

dc

Madhu

12:23 pm on Aug 2, 2007 (gmt 0)

10+ Year Member



Thank u DC

It is working now

Madhu

4:42 am on Aug 3, 2007 (gmt 0)

10+ Year Member




System: The following message was spliced on to this thread from: http://www.webmasterworld.com/php/3412531.htm [webmasterworld.com] by encyclo - 5:50 am on Aug. 3, 2007 (utc -4)


Hi all
i have to design a combo box in php with more number of letters (example: Anna university college of engineering) but the space for the combo is little .
So now i tried as below in php,
$college="Anna university college of engineering";
substr($college,0,20);

But it is displayed as " Anna university colle "
I want it to display as " Anna university col.. "
Plz help if anybody knows
Thanks in advance,
Madhu

Habtom

10:56 am on Aug 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can keep it very simple.

This is what you have:

substr($college,0,20);

//Assign to a variable and deduct three (for your three dots):
$str = substr($college,0,17);

//Check if the lenght is not infact less than 17
if (strlen($str) > 17) {
//If it is not attach the three dots
$str = $str."...";
}

Hope this helps.