Jump to content

inserting date into database


Recommended Posts

hi there

wonder if anyone can point me in the right direction with this one. I want to create a form where a user enters the date of an event. at present the only way i can manage this is if i get the user to enter todays date in a text box as (eg todays date) 20051227 which is sure going to confuse people.

What i'm wondering is how complex a procedure, taking into account my noobie status, would it be to enter the date into one columns of a database using three drop down menus. Any help much appreciated

thanks

Link to comment
Share on other sites

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--][span style=\"color:#0000BB\"]<?php

[/span][span style=\"color:#007700\"]if(isset([/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'submit\'[/span][span style=\"color:#007700\"]]))

{

     [/span][span style=\"color:#0000BB\"]$month [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'month\'[/span][span style=\"color:#007700\"]];

     [/span][span style=\"color:#0000BB\"]$day [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'day\'[/span][span style=\"color:#007700\"]];

     [/span][span style=\"color:#0000BB\"]$year [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'year\'[/span][span style=\"color:#007700\"]];

 

     [/span][span style=\"color:#0000BB\"]$eventDate [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$month [/span][span style=\"color:#007700\"]. [/span][span style=\"color:#DD0000\"]\" \" [/span][span style=\"color:#007700\"]. [/span][span style=\"color:#0000BB\"]$day [/span][span style=\"color:#007700\"]. [/span][span style=\"color:#DD0000\"]\", \" [/span][span style=\"color:#007700\"]. [/span][span style=\"color:#0000BB\"]$year[/span][span style=\"color:#007700\"];

 

     echo([/span][span style=\"color:#0000BB\"]$eventDate[/span][span style=\"color:#007700\"]);

}

else

{

[/span][span style=\"color:#0000BB\"]?>

[/span]<form action=\"[span style=\"color:#0000BB\"]<?=$_SERVER[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'PHP_SELF\'[/span][span style=\"color:#007700\"]][/span][span style=\"color:#0000BB\"]?>[/span]\" method=\"post\">

Enter Event Date: <select name=\"month\">

     <option value=\"Jan\">Jan</option>

     <option value=\"Feb\">Feb</option>

     <option value=\"Mar\">Mar</option>

     <option value=\"April\">April</option>

</select>

 

<select name=\"day\">

     <option value=\"1\">1</option>

     <option value=\"2\">2</option>

     <option value=\"3\">3</option>

     <option value=\"4\">4</option>

     <option value=\"5\">5</option>

     <option value=\"6\">6</option>

     <option value=\"7\">7</option>

</select>

 

<select name=\"year\">

     <option value=\"2005\">2005</option>

     <option value=\"2006\">2006</option>

</select>

 

<input type=\"submit\" value=\"Submit\" name=\"submit\">

</form>

[span style=\"color:#0000BB\"]<?php

[/span][span style=\"color:#007700\"]}

[/span][span style=\"color:#0000BB\"]?>[/span]

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

 

All you have to do is concatenate all of the values of the selects. You can format it however you want.

 

Jeremy

Link to comment
Share on other sites

thanks for that

the principle makes sense, just that when i pasted the code i got the following error

 

Parse error: parse error, unexpected T_VARIABLE in /home/fhlinux195/m/matthewtennant.com/user/htdocs/mainevent_1.php on line 9

 

i'm guessing i'm making a massive error. All the code belongs in the same page right??

 

thanks again

mat

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.