need help using substr on mysql update record

rogergi

New Member
good evening all,i have been trying to update records but can't seem to code in the substr command to extract certain details from a string.i have a doa (date of accident) text field currently working with kelvinluck's jquery datepicker plugin.originally the single doa textfield was split into three drop downs... namely: doaDay, doaMonth, doaYear. each had their own field in the database as well.but i've decided to unify the doaDay, doaMonth, doaYear into one single field... called doa and us kevinluck's jquery datepicker plugin.now as i have well over a 100 records in my database using the doaDay,doaMonth,doaYear fields i decided to use the substr command in order to extract the dd (doaDay), mm (doaMonth) and yyyy (doaYear) from the new updated dd/mm/yyyy (field).this was my solution when INSERTING the database:\[code\]$doa = $_POST['doa'];$doaDay = substr($doa, 0, 2);$doaMonth = substr($doa, 4, 5);$doaYear = substr($doa, 7, 10);\[/code\]then the record was inserted after POST.\[code\]mysql_query("INSERT INTO tbl_personalinjury (`doaDay`, `doaMonth`, `doaYear`) VALUES ('$doaDay', '$doaMonth', '$doaYear')");\[/code\]now the problem arises when im trying to update the record. as a completely new method is used and i am having difficulty implementing it. here is what i have so far.\[code\]if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form")) { $updateSQL = sprintf("UPDATE tbl_accident SET doaDay=%s, doaMonth=%s, doaYear=%s, WHERE id=$client_id", GetSQLValueString($_POST['doaDay'], "text"), GetSQLValueString($_POST['doaMonth'], "text"), GetSQLValueString($_POST['doaYr'], "text"),\[/code\]how do i go about extracting dd, mm, yyyy from the doa textfield and assigning the values to $doaDay, $doaMonth, and $doaYear respectively. i would appreciate any advice.God bless.
 
Back
Top