spacepoet Posted January 11, 2012 Share Posted January 11, 2012 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! Quote Link to comment https://forums.phpfreaks.com/topic/254769-dynamically-make-all-uppercase-to-capitalize/ Share on other sites More sharing options...
trq Posted January 11, 2012 Share Posted January 11, 2012 strtolower then ucfirst or ucwords. Quote Link to comment https://forums.phpfreaks.com/topic/254769-dynamically-make-all-uppercase-to-capitalize/#findComment-1306357 Share on other sites More sharing options...
spacepoet Posted January 11, 2012 Author Share Posted January 11, 2012 Hi ... Could you possibly give me an example of how to add that? I really do not know where to start with it... Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/254769-dynamically-make-all-uppercase-to-capitalize/#findComment-1306632 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.