Jump to content

Archived

This topic is now archived and is closed to further replies.

catlover

*SOLVED* Changing values help.

Recommended Posts

In a previous post LordStanley (Thanks LordStanley!) was able to help me with this code:

[code]<table class="text1" width="100%" border="0" cellpadding="2" cellspacing="0"> <?

$result=mysql_query("SELECT breed, count(breed) as num FROM animals GROUP BY breed")or die( "Error! Could not select the database: " . mysql_error() );
while ($category = mysql_fetch_array($result))  {

echo '<tr>
<td width="11"><img src="images/down_arrow.jpg" width="10" height="10"></td>
<td width="100%"><a href="'.$path.$category['breed'].'.php">'.$category['breed'].'</a>
<a href="'.$path.$category['breed'].'.php">
( '.$category['num'].')';
}[/code]


The value of "$path.$category['breed']" returns lowercase value with "_" between values containing more than one word.... ie. "american_bobtail". It is returned this way because the pages the link will point to are named lowercase, and using underscore between words for browser url reasons.

But, I need the "menu" this script is building to show Uppercase values.

Like (sorry, not actual code):

[code] if $category['breed'] = 'american_bobtail' {

$category = 'American Bobtail'

}[/code]

How can I make this work?

Thanks for any help that can be provided!

Share this post


Link to post
Share on other sites
Example:

$data = ucfirst(str_replace('_', ' ', $data));

See:

[a href=\"http://us2.php.net/manual/en/function.ucfirst.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.ucfirst.php[/a]

[a href=\"http://us2.php.net/manual/en/function.str-replace.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.str-replace.php[/a]

Share this post


Link to post
Share on other sites
The ucfirst() function will only change the first word to initial caps. Use the function ucwords() to make all the words inital caps. Or you can use CSS and the "text-transform: capitalize" style.

Ken

Share this post


Link to post
Share on other sites
[!--quoteo(post=360898:date=Apr 2 2006, 08:05 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 2 2006, 08:05 AM) [snapback]360898[/snapback][/div][div class=\'quotemain\'][!--quotec--]
The ucfirst() function will only change the first word to initial caps. Use the function ucwords() to make all the words inital caps. Or you can use CSS and the "text-transform: capitalize" style.

Ken
[/quote]
I used ucfirst() on purpose because that's what catlover showed he/she wanted by showing 'American Bobtail'.

Share this post


Link to post
Share on other sites
Thanks toplay and kenrbnsn

A combination of both of your suggestions and a little extra elbow-grease accomplished the job!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.