FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » problem saving date fields
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
problem saving date fields [message #174052] Fri, 20 May 2011 18:38 Go to previous message
Co is currently offline  Co
Messages: 75
Registered: May 2011
Karma:
Member
Hi All,

I have two date fields.
When I change of them the other one gets set back to default:
00-00-0000
I have to save both to make it work. Is there a solution for this?

The arrival_date and departure_date are build up like this:

<select name="arrival_day" class="formFields" id="arrival_day">
<option value="<?php print "$arrival_day"; ?>"><?php print
"$arrival_day"; ?></option>
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option> etc......

<select name="arrival_month" class="formFields" id="arrival_month">
<option value="<?php print "$arrival_month"; ?>"><?php print
"$arrival_month"; ?></option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option> etc......

<select name="arrival_year" class="formFields" id="arrival_year">
<option value="<?php print "$arrival_year"; ?>"><?php print
"$arrival_year"; ?></option>
<option value="2011">2013</option>
<option value="2011">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option> etc......

The table is updated like this:

$arrival_month = preg_replace('#[^0-9]#i', '',
$_POST['arrival_month']);
$arrival_day = preg_replace('#[^0-9]#i', '',
$_POST['arrival_day']); // filter everything but numbers
$arrival_year = preg_replace('#[^0-9]#i', '',
$_POST['arrival_year']); // filter everything but numbers
$arrival_date = "$arrival_year-$arrival_month-$arrival_day";

$departure_month = preg_replace('#[^0-9]#i', '',
$_POST['departure_month']);
$departure_day = preg_replace('#[^0-9]#i', '',
$_POST['departure_day']); // filter everything but numbers
$departure_year = preg_replace('#[^0-9]#i', '',
$_POST['departure_year']); //
$departure_date = "$departure_year-$departure_month-$departure_day";

$sqlUpdate = mysql_query("UPDATE myMembers SET
firstname='$firstname', lastname='$lastname', gender='$gender',
partner='$partner', country='$country', rank='$rank',
service='$service', position='$position',
arrival_date='$arrival_date',departure_date='$departure_date' WHERE
id='$id' LIMIT 1");

Is there a reason why this happens? I do create the right format to
put the data back in the table.

Regards
Marco
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: is dis da place?
Next Topic: foreach in reverse
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 18:07:28 GMT 2024

Total time taken to generate the page: 0.06272 seconds