Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #1845
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: problem saving date fields |
| Date | 2011-05-26 05:43 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <irl7c5$fth$1@dont-email.me> (permalink) |
| References | (16 earlier) <411fb286-a311-4b96-a32f-826bfac7a29b@cu4g2000vbb.googlegroups.com> <ireleg$8pj$1@dont-email.me> <2eac019a-b357-4de0-96b3-aed7b9b1dc85@y31g2000vbp.googlegroups.com> <irfuno$p2u$1@dont-email.me> <8bbf6db3-ac7b-4d72-9e70-5c9915920e66@z19g2000yqz.googlegroups.com> |
On 5/26/2011 5:10 AM, Co wrote:
> On 24 mei, 12:45, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>> On 5/24/2011 1:30 AM, Co wrote:
>>
>>
>>
>>> On 24 mei, 00:00, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>>>> 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).
>>
>>> Are you saying that all this coding was necessary if I had
>>> straightened out
>>> my select code?
>>
>>> Marco
>>
>> No, all that coding is UNNECESSARY if you straighten out your select code.
>>
>> You do still want to validate the input, but it's much less complex -
>> i.e. in your case all you need to do is ensure the value is an integer
>> (check out intval()). And if it is not, just reject the input. No need
>> to try to correct it.
>>
>
> Jerry,
>
> that doesn't solve my problem.
> It just tells me that there is a dead end street.
>
> Marco
Marco, I gave you hints on how to code your html. Learn how to do it
properly. And if you need html help, try an html newsgroup.
--
==================
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
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