PHP - Ucwords
i want to be able to use ucwords in my whole return results. i know this works.
$choice1 = ucwords($rows['auth']); BUT. my query returns 14 $rows of data so i thought of doing this instead of doing a new chunk of code for each row. $sql = "SELECT * from dsgi_serval $column "; $result1=mysql_query($sql); $result = ucwords($'result1'); while($rows=mysql_fetch_array($result)){ echo "$rows"; } needless to say that does not work. i have tried to google this but i only get matches for manual arrays and not an sql query. is there a way of doing this? Thanks Similar TutorialsI have a registration page I am creating which passes Ajax data from a form to the function ProcessSignUpData. I am trying to use ucwords on this function for the name, address and city form fields and it isn't working. Any Suggestions what be greatly appreciated! If I am not providing enough information, please let me know! Here is what the code looks like: if ($_POST['ProcessSignUpData']) { usleep(3500000); unset($Data); $Data['OldCardNbr'] = substr(preg_replace("/[^0-9]*/", "", $_POST['SavingsClub']), -8); $Data['FName'] = ucwords($_POST['FirstName']); $Data['LName'] = ucwords($_POST['LastName']); $Data['Address1'] = ucwords($_POST['Address1']); $Data['Address2'] = ucwords($_POST['Address2']); $Data['City'] = ucwords($_POST['City']); $Data['State'] = $_POST['State']; $Data['Zip'] = preg_replace("/[^0-9]*/", "", $_POST['ZipCode']); if (ValidateEMail($_POST['EMail'])) $Data['EmailAddr'] = $_POST['EMail']; $Data['HPhone'] = phone_format($_POST['HomePhone']); $Data['WPhone'] = phone_format($_POST['MobilePhone']); $Data['BirthYear'] = preg_replace("/[^0-9]*/", "", $_POST['BirthYear']); $Data['BirthMo'] = preg_replace("/[^0-9]*/", "", $_POST['BirthMonth']); $Data['Sex'] = preg_replace("/[^MF]*/", "", $_POST['Gender']); $NumberOfCards = preg_replace("/[^0-9]*/", "", $_POST['NumberOfCards']); if ($Data['FName'] && $Data['LName'] && $Data['Address1'] && $Data['City'] && $Data['Zip']) { // Check to see if the person is already signed up with a new card number (dupliate signup check) $IsDup = FALSE; // First check database SCVL1 $My->query("select `MembNbr`, `HPhone`, `EmailAddr`, `OldCardNbr` from `member` where `FName` = '" . $My->escape($Data['FName']) . "' and `LName` = '" . $My->escape($Data['LName']) . "' and `State` = '" . $My->escape($Data['State']) . "' and substr(`Zip`, 1, 5) = '" . $My->escape(substr($Data['Zip'], 0, 5)) . "'"); if ($DupCheck = $My->fetchArray()) { do { if (substr($DupCheck['MembNbr'], 0, 1) == "6") { $IsDup = TRUE; if ($Data['EmailAddr'] && $DupCheck['EmailAddr']) { if ($Data['EmailAddr'] != $DupCheck['EmailAddr']) { $IsDup = FALSE; } } if ($Data['HPhone'] && $DupCheck['HPhone']) { if ($Data['HPhone'] != $DupCheck['HPhone']) { $IsDup = FALSE; } } } if ($IsDup === TRUE) break; } while ($DupCheck = $My->fetchArray()); } // Then check database SCVL3 if no dup found in SCVL1 if ($IsDup === FALSE) { $My3->query("select `MembNbr`, `HPhone`, `EmailAddr`, `OldCardNbr` from `tblmember` where `FName` = '" . $My->escape($Data['FName']) . "' and `LName` = '" . $My->escape($Data['LName']) . "' and `State` = '" . $My->escape($Data['State']) . "' and substr(`Zip`, 1, 5) = '" . $My->escape(substr($Data['Zip'], 0, 5)) . "'"); if ($DupCheck = $My3->fetchArray()) { do { if (substr($DupCheck['MembNbr'], 0, 1) == "6") { $IsDup = TRUE; if ($Data['EmailAddr'] && $DupCheck['EmailAddr']) { if ($Data['EmailAddr'] != $DupCheck['EmailAddr']) { $IsDup = FALSE; } } if ($Data['HPhone'] && $DupCheck['HPhone']) { if ($Data['HPhone'] != $DupCheck['HPhone']) { $IsDup = FALSE; } } } if ($IsDup === TRUE) break; } while ($DupCheck = $My3->fetchArray()); } } // Show an error if a dup was found if ($IsDup === TRUE) { I need to add ucwords so that the first letter is caps in POST data. Not sure where to put in within this. echo $_POST['name']; new account form has the usual; firstname, last name company, street address etc.
Talents write in ALL uppercase, lowercase everything but proper case.
Don't know where to apply ucwords and strtolower to convert values into proper case.
Code as is:
<form action="https://www.website.com/?page=step3" method="POST" name=myForm id="commentForm" class="cmxform"> Hi I have the following for an input form, I was under the impression that ucwords would format the text into Initial Characters, but this does not do that? What have I done wrong? $ven_name = trim(ucwords(mysql_prep($_POST['ven_name']))); |