catlover Posted April 2, 2006 Share Posted April 2, 2006 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! Quote Link to comment Share on other sites More sharing options...
toplay Posted April 2, 2006 Share Posted April 2, 2006 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] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 2, 2006 Share Posted April 2, 2006 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 Link to comment Share on other sites More sharing options...
toplay Posted April 2, 2006 Share Posted April 2, 2006 [!--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'. Quote Link to comment Share on other sites More sharing options...
catlover Posted April 2, 2006 Author Share Posted April 2, 2006 Thanks toplay and kenrbnsnA combination of both of your suggestions and a little extra elbow-grease accomplished the job! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.