Jump to content


Photo

*SOLVED* Changing values help.


  • Please log in to reply
4 replies to this topic

#1 catlover

catlover
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 02 April 2006 - 02:39 PM

In a previous post LordStanley (Thanks LordStanley!) was able to help me with this 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'].')';
}


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):

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

$category = 'American Bobtail'

}

How can I make this work?

Thanks for any help that can be provided!

#2 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 02 April 2006 - 02:53 PM

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]

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 02 April 2006 - 04:05 PM

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

#4 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 02 April 2006 - 04:10 PM

[!--quoteo(post=360898:date=Apr 2 2006, 08:05 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 2 2006, 08:05 AM) View Post[/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'.


#5 catlover

catlover
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 02 April 2006 - 05:05 PM

Thanks toplay and kenrbnsn

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users