Inserting, storing, outputting dates and selections

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux