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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.