Deanznet Posted May 19, 2009 Share Posted May 19, 2009 Okay this is a date of birth... Drop down menu... I need to pass it in this format dd-m-yr Okay i have 3 drop down menus dd and Month and Yr i need to combin all these into 1 field and make the variable birthdate if you understand. Hpw!? Quote Link to comment Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 VARCHAR(10)? Quote Link to comment Share on other sites More sharing options...
DarkSuperHero Posted May 19, 2009 Share Posted May 19, 2009 take your $_POST of $_GET variables and isert it into your database... eg $queryString = "INSERT INTO tableName (`id`,`birthday`) VALUES('',$_GET['dd']-$_GET['Month']-$_GET['Yr'])" Quote Link to comment Share on other sites More sharing options...
waynewex Posted May 19, 2009 Share Posted May 19, 2009 Better to do some checking. <?php if(intval($_GET['dd']) == 0 || intval($_GET['Month']) == 0 || intval($_GET['Yr'])){ //error } else{ if(!checkdate($_GET['Month'],$_GET['dd'],$_GET['Yr'])){ //error - isn't really a date (32 of Feb etc?) } else{ $dob = mysql_real_escape_string($_GET['Yr'].'-'.$_GET['Month'].'-'.$_GET['dd']); $query = "INSERT INTO tablename (id,dob) VALUES ('$id','$dob')"; $insert = mysql_query($query) or trigger_error(mysql_error()); if($insert == 1){ //row was inserted - success } } } ?> Quote Link to comment Share on other sites More sharing options...
waynewex Posted May 19, 2009 Share Posted May 19, 2009 Okay this is a date of birth... Drop down menu... I need to pass it in this format dd-m-yr Okay i have 3 drop down menus dd and Month and Yr i need to combin all these into 1 field and make the variable birthdate if you understand. Hpw!? Why do you need to pass it in dd - m - yr format? By doing that you lose out on some pretty powerful MySQL date functions. Surely you should add it to a date column, and if needs be, re-format the date after extraction to suit your needs? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.