i have this code that will get the date from looping input, make it array using map function.
var target_completion_date = $('input#target_completion_date').map(function() {
return $(this).val();
}).get();
The Output of this JavaScript is like this in string array:
27/1/2014,25/1/2014,29/1/2014
The question is, how can I code the update MySQL or convert (27/1/2014,25/1/2014,29/1/2014) to (2014-01-27,2014-01-25,2014-01-25) before it save and update to database:
$target_completion_date = $_POST['target_completion_date'];
> for ($i = 0; $i <5;) {
> $sql1 = "UPDATE AT_tna_assessment SET identify_needs = '$identify_needs[$i]', activity_required = '$part_c_activity[$i]',
> priority = '$part_c_priority[$i]', **target_completion_date = ?** , remarks = '$part_c_remark[$i]'
> WHERE id ='$part_c_id[$i]'";
> mysql_query($sql1) or die ("Cant Connect");
$i++;
}
I have use target_completion_date = DATE(STR_TO_DATE('$target_completion_date[$i]','%m-%d-%Y'));
but not working
I GOT ALREADY MY ANSWER. THANKS ALL
I have solve this problems by this code. Thanks :)
for ($i = 0; $i <5;) {
$tb = explode("/", ($target_completion_date[$i]));
date_duration_from[$i] = $tb[2] . "-" . $tb[1] . "-" . $tb[0].",";
$sql1 = "UPDATE AT_tna_assessment SET identify_needs = '$identify_needs[$i]', activity_required = '$part_c_activity[$i]', priority = '$part_c_priority[$i]', target_completion_date= '$date_duration_from[$i]' , remarks = '$part_c_remark[$i]' WHERE id
='$part_c_id[$i]'";
mysql_query($sql1) or die ("Cant Connect");
$i++;
}