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!? Link to comment https://forums.phpfreaks.com/topic/158698-help-passing-this-field/ Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 VARCHAR(10)? Link to comment https://forums.phpfreaks.com/topic/158698-help-passing-this-field/#findComment-836953 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'])" Link to comment https://forums.phpfreaks.com/topic/158698-help-passing-this-field/#findComment-836988 Share on other sites More sharing options...
waynew 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 } } } ?> Link to comment https://forums.phpfreaks.com/topic/158698-help-passing-this-field/#findComment-836992 Share on other sites More sharing options...
waynew 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? Link to comment https://forums.phpfreaks.com/topic/158698-help-passing-this-field/#findComment-836996 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.