I have an input mask that is setting an input mask for the users. It's perfect because they can type in 1230 and it was come out as 12:30. From there, they choose a dropdown box for AM/PM. It's perfect. Ideally, I don't want to change it.
I am entering the data in as such:
Code: Select all
mysql_query("INSERT INTO missedVisit (missed_aptTime) VALUES ('".trim(addslashes($_POST['missed_aptTime']))."')"); Code: Select all
$updateSQL = sprintf("UPDATE missedVisit SET missed_aptTime=%s WHERE missed_id=%s",
GetSQLValueString(trim(addslashes($_POST['missed_aptTime'])), "text"),
GetSQLValueString(trim($_POST['missed_id']), "int"));
mysql_select_db($database_contacts, $contacts);
$Result1 = mysql_query($updateSQL, $contacts) or die(mysql_error());Now, the PHP:
Code: Select all
<input name="missed_aptTime" type="text" class="text input_mask mask_time" id="missed_aptTime" size="6" maxlength="5" value="<?php echo $row_missed['missed_aptTime']; ?>"/>
<select name="missed_aptTimeAMPM" id="missed_aptTimeAMPM">
<option value=" " selected="selected"> </option>
<option value="AM"<?php if (!(strcmp("AM", $row_missed['missed_aptTimeAMPM']))) {echo "selected=\"selected\"";} ?>>AM</option>
<option value="PM"<?php if (!(strcmp("PM", $row_missed['missed_aptTimeAMPM']))) {echo "selected=\"selected\"";} ?>>PM</option>
</select>The issue at hand is: I enjoy the input mask and it's ease of use. I would like it be able to insert this time into the database. If I need to modify the database fields, I can. But right now, when I insert this, I get a result for 12:30 in the field as 12 or for 05:30 as 05. It only goes to the colon.
I am aware that this needs to conform to TIME or TIMESTAMP or DATETIME, but I don't want to severely modify my stinkin' input mask and form layout.
Anyone know what I can do to make this happen? If it needs to be a string, that's fine, but how do I do it? If I need to convert the HH:MM to HH:MM:SS, i'm okay with that and changing the field type too, but how? I'm lost.
Much thanks appreciated.