From: David Mehler on
Hello,
I've got two questions which are probably fairly simple, my issue is
i'm staring at this so long it's blurring together.
I'm working on a form to insert data in to a mysql database. I've got
a startdate and and enddate field in the database both of type DATE,
i'm needing this as i'm wanting to do a calculation against the date
and only display records greater than or equal to the current date. My
understanding is dates have to be entered as 2010-06-02 with this
format.
I'm having several issues: the first of which is I entered a date as
probably a user would as June 2, 2010 and on the display page got all
zeroes, is there a way i can be more flexible with my data entry,
enter it, then store it in the format mysql needs?
My second issue is that the startdate field is NOT NULL while the
enddate field is. On submission I only want those forms that are
actually in the post data to get inserted in to the database, and
displayed, i.e. if enddate was not entered I shouldn't see all zeroes
in the field in the database, if using the mysql commandline client,
or all zeroes in displayed output. I'm not sure how to conditionally
insert or display a field based on whether it's set.
My last issue, not on dates, is on a selection box. I've got two
choices to choose from, choice1 and choice2 just for this example. If
a user goes through and selects nothing I want choice1 to be
automatically selected on form submission, if a user selects choice2
then the form should go with that. Here's my code.

<div>
<label for="txtchoose">Choose*:</label>
<select name="Choice for Selection">
<option> - choice1 - </option>
<option> - choice2 - </option>
</select>
</div>

On form submission the php script processes it and enters an empty
field in the database if the user doesn't select an option.
Thanks.
Dave.
From: Shreyas on
I can try to answer the second one but would wait for the PHP gurus to chime
in.

Can't you have Choice=1 with selected="true" by default? On the PHP end, you
can get the value of whatever was selected.

Regards,
Shreyas

On Thu, Jun 3, 2010 at 1:50 AM, David Mehler <dave.mehler(a)gmail.com> wrote:

> Hello,
> I've got two questions which are probably fairly simple, my issue is
> i'm staring at this so long it's blurring together.
> I'm working on a form to insert data in to a mysql database. I've
> got
> a startdate and and enddate field in the database both of type DATE,
> i'm needing this as i'm wanting to do a calculation against the date
> and only display records greater than or equal to the current date. My
> understanding is dates have to be entered as 2010-06-02 with this
> format.
> I'm having several issues: the first of which is I entered a date as
> probably a user would as June 2, 2010 and on the display page got all
> zeroes, is there a way i can be more flexible with my data entry,
> enter it, then store it in the format mysql needs?
> My second issue is that the startdate field is NOT NULL while the
> enddate field is. On submission I only want those forms that are
> actually in the post data to get inserted in to the database, and
> displayed, i.e. if enddate was not entered I shouldn't see all zeroes
> in the field in the database, if using the mysql commandline client,
> or all zeroes in displayed output. I'm not sure how to conditionally
> insert or display a field based on whether it's set.
> My last issue, not on dates, is on a selection box. I've got two
> choices to choose from, choice1 and choice2 just for this example. If
> a user goes through and selects nothing I want choice1 to be
> automatically selected on form submission, if a user selects choice2
> then the form should go with that. Here's my code.
>
> <div>
> <label for="txtchoose">Choose*:</label>
> <select name="Choice for Selection">
> <option> - choice1 - </option>
> <option> - choice2 - </option>
> </select>
> </div>
>
> On form submission the php script processes it and enters an empty
> field in the database if the user doesn't select an option.
> Thanks.
> Dave.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Regards,
Shreyas