Jump to content

Dynamically Make ALL UPPERCASE to Capitalize ...?


spacepoet

Recommended Posts

Hello:

 

I have this little bit of code to pull all the towns and zip codes from a mySQL database:

<?php

$result = mysql_query("SELECT zip_id,city,abbr_state,full_state,zip FROM zip_codes WHERE abbr_state = '" . mysql_real_escape_string ( $_GET['abbr_state'] ) . "' ORDER BY `city` ASC");

while($row = mysql_fetch_array($result))

{

echo "<a href=\"Stores.php?zip_id=".$row['zip_id']."\"  title=\"My Products ". $row['city']. ", ". $row['abbr_state']." ". $row['zip']." | My Items ". $row['city']. ", ". $row['abbr_state']." ". $row['zip']."\">". $row['city']. ", ". $row['abbr_state']." ". $row['zip']."</a>";
echo "<div style=\"clear: both; margin-bottom: 15px;\"></div>";

}

?>

 

Works fine (unless some can offer a way to "improve" the code).

 

However, all of the City Names ($row['city']) were put into the database as ALL CAPITALS, which is a bit harder on the eyes to read.

 

Is there a "PHP way" - working with the code I posted - that will transform the ALL CAPITALS to a more readable Capitalize (in other words, Capitalize just the first letter of each town).

 

I know that CSS offers "text-transform" and if that is a solution I'm fine with that.

 

I just need it to display that way, not re-write it in the database.

 

Ideas? Solution?

 

Thanks!

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.