Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #1818

Re: problem saving date fields

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: problem saving date fields
Date 2011-05-23 18:00 -0400
Organization A noiseless patient Spider
Message-ID <ireleg$8pj$1@dont-email.me> (permalink)
References (14 earlier) <e74cd181-0d6a-4c5b-af54-ae3ae9b6279c@gv8g2000vbb.googlegroups.com> <irdfg5$v84$1@dont-email.me> <14983f67-9bfd-4ac0-bfd9-ef82fb30a952@gv8g2000vbb.googlegroups.com> <ire89l$9bn$1@dont-email.me> <411fb286-a311-4b96-a32f-826bfac7a29b@cu4g2000vbb.googlegroups.com>

Show all headers | View raw


On 5/23/2011 3:17 PM, Co wrote:
> On 23 mei, 20:16, Jerry Stuckle<jstuck...@attglobal.net>  wrote:
>> On 5/23/2011 1:27 PM, Co wrote:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> On 23 mei, 13:13, Jerry Stuckle<jstuck...@attglobal.net>    wrote:
>>>> On 5/23/2011 12:51 AM, Co wrote:
>>
>>>>>> ==================
>>
>>>>> Wow you guys really love each other.
>>
>>>>> Marco
>>
>>>> Yea, unfortunately, you have to put up with some trolls on usenet.
>>
>>> So when one of the three dates is not changed it returns the month
>>> written.
>>> Than this code:
>>> $arrival_month = preg_replace('#[^0-9]#i', '',
>>> $_POST['arrival_month']);
>>> ruins the date and it gets set back to 00-00-0000.
>>> Is there a way to detect changes? because than I could set an if
>>> statement before
>>> running the UPDATE query and we leave out the dates that were not
>>> changed.
>>
>>> Marco
>>
>> OK, the question is, where is it getting the month name instead of the
>> number?  It has to be coming from your html code.  Look at the page
>> source and see where you're putting 'April' in there instead of 4.
>>
>> As for detecting when the data changed - the only way is to do something
>> like save the current data in your $_SESSION and compare when it is
>> retrieved.  However, that isn't necessary if you get your problem with
>> the month name being retrieved.  It doesn't hurt to update a value in
>> the database with the same value.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================
>
> It is getting the name of the month when the pulldown menu is filled.
>
> <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>
> <option value="05">May</option>
> <option value="06">June</option>
> <option value="07">July</option>
> <option value="08">August</option>
> <option value="09">September</option>
> <option value="10">October</option>
> <option value="11">November</option>
> <option value="12">December</option>
> </select>
>
> The problem is that during the Post it returns the name instead of the
> number.
>
> I tried this code but when I don't change the month it doesn't pass
> the code:
> if(!is_numeric($arrival_month)) {
>
> for($i=1;$i<=12;$i++){
>     if(strtolower(date("M", mktime(0, 0, 0, $i, 1, 0))) ==
> strtolower($arrival_month)){
> 	        $arrival_month = $i;
> 					 }
>     				}
> print $arrival_month;
> }
>
> Marco

Of course it will.  You have:

<option value="<?php print "$arrival_month"; ?>"><?php print 
"$arrival_month"; ?></option>

Which has the month name as its option value.  If the arrival month were 
April, you would have two Aprils - the first one in the SELECT element 
with a value of 'April', then one later with a value of '4'.

You need to straighten out your HTML.  You only need one  APRIL.  Look 
up the SELECT/OPTION element and learn how to display the previously 
selected value instead of the first value (hint: look for the SELECTED 
keyword).

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

problem saving date fields Co <vonclausowitz@gmail.com> - 2011-05-20 11:38 -0700
  Re: problem saving date fields Luuk <Luuk@invalid.lan> - 2011-05-20 20:50 +0200
  Re: problem saving date fields Jeff North <jnorthau@yahoo.com.au> - 2011-05-21 08:58 +1000
    Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-20 22:35 -0400
      Re: problem saving date fields Jeff North <jnorthau@yahoo.com.au> - 2011-05-21 13:13 +1000
        Re: problem saving date fields Co <vonclausowitz@gmail.com> - 2011-05-20 23:47 -0700
          Re: problem saving date fields Co <vonclausowitz@gmail.com> - 2011-05-21 00:18 -0700
            Re: problem saving date fields Luuk <Luuk@invalid.lan> - 2011-05-21 09:54 +0200
            Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-21 10:37 -0400
              Re: problem saving date fields Co <vonclausowitz@gmail.com> - 2011-05-21 08:07 -0700
                Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-21 19:55 -0400
                Re: problem saving date fields Co <vonclausowitz@gmail.com> - 2011-05-22 14:20 -0700
                Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-22 17:28 -0400
        Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-21 10:32 -0400
          Re: problem saving date fields Jeff North <jnorthau@yahoo.com.au> - 2011-05-22 02:08 +1000
            Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-21 20:01 -0400
              Re: problem saving date fields "Twayne" <nobody@devnull.spamcop.net> - 2011-05-21 20:30 -0400
                Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-21 23:13 -0400
              Re: problem saving date fields Jeff North <jnorthau@yahoo.com.au> - 2011-05-22 14:28 +1000
                Re: problem saving date fields Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-22 12:45 +0200
                Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-22 08:26 -0400
                Re: problem saving date fields "Twayne" <nobody@devnull.spamcop.net> - 2011-05-22 09:20 -0400
                Re: problem saving date fields Jeff North <jnorthau@yahoo.com.au> - 2011-05-23 00:08 +1000
                Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-22 13:47 -0400
                Re: problem saving date fields Bill B <me@privacy.net> - 2011-05-22 14:17 -0400
                Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-22 14:26 -0400
                Re: problem saving date fields Bill B <me@privacy.net> - 2011-05-22 16:27 -0400
                Re: problem saving date fields Jeff North <jnorthau@yahoo.com.au> - 2011-05-23 09:01 +1000
                Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-22 20:21 -0400
                Re: problem saving date fields Bill B <me@privacy.net> - 2011-05-22 21:36 -0400
                Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-22 21:46 -0400
                Re: problem saving date fields Jeff North <jnorthau@yahoo.com.au> - 2011-05-23 12:20 +1000
                Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-22 22:30 -0400
                Re: problem saving date fields Co <vonclausowitz@gmail.com> - 2011-05-22 21:51 -0700
                Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-23 07:13 -0400
                Re: problem saving date fields Co <vonclausowitz@gmail.com> - 2011-05-23 10:18 -0700
                Re: problem saving date fields Co <vonclausowitz@gmail.com> - 2011-05-23 10:27 -0700
                Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-23 14:16 -0400
                Re: problem saving date fields Co <vonclausowitz@gmail.com> - 2011-05-23 12:17 -0700
                Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-23 18:00 -0400
                Re: problem saving date fields Co <vonclausowitz@gmail.com> - 2011-05-23 22:30 -0700
                Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-24 05:45 -0400
                Re: problem saving date fields Co <vonclausowitz@gmail.com> - 2011-05-26 02:10 -0700
                Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-26 05:43 -0400
                Re: problem saving date fields Co <vonclausowitz@gmail.com> - 2011-05-23 14:26 -0700
                Re: problem saving date fields Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-23 18:01 -0400
                Re: problem saving date fields Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-23 23:59 +0200
                Re: problem saving date fields "Twayne" <nobody@devnull.spamcop.net> - 2011-05-22 09:11 -0400

csiph-web