Jump to content

*SOLVED* Changing values help.


catlover

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!
Link to comment
https://forums.phpfreaks.com/topic/6398-solved-changing-values-help/
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]
[!--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'.

Archived

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

×
×
  • Create New...

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.