StefanRSA Posted August 24, 2009 Share Posted August 24, 2009 I created a form with dynamic fields. The field types and names are created and saved in a DB. I then populate a form with the dynamic field as well as a few standard fields. One field set is a checkbox and the other short text. When I try to send the $_Post of the dynamic fields to the DB only the first field is send to the DB. What am I doing wrong? My Code to get a handle on the Dynamic fields is working as follow: $query = mysql_query("SELECT * FROM field_name WHERE sub_id = '$adsubcat'") or die(mysql_error()); while($rows = mysql_fetch_array($query)){ $ftype= $rows['field_type']; $ftitle= $rows['field_title']; $f_id = $rows['id']; $fname= $rows['field_name']; $fcomp= $rows['compulsory']; $fval= $rows['val']; $fhelp= $rows['help']; $fid= $rows['help']; ///Posted field start here $postedfield =trim($_POST[$fname]); /////////////////////////////////////////SELECT BOX FIELD START///////////////////// if ($ftype=='select'){ $c=$_REQUEST["$fname"]; for($i=0;$i<count($c);$i++) { $val=$c[$i]; $sql="INSERT INTO adfields(adid, f_id, f_title, f_name, f_type, f_value, ad_user) VALUES ('$adnr', '$f_id', '$ftitle', '$fname', '$ftype','$val','$userid')"; $res=mysql_query($sql); echo $val; } } /////////////////////////////////////////SELECT BOX FIELD END ////////////////////// else { //// ALL OTHER FIELDS START $query = mysql_query("INSERT INTO adfields (adid, f_id, f_title, f_name, f_type, f_value, ad_user) VALUES ('$adnr', '$f_id', '$ftitle', '$fname', '$ftype', '$postedfield','$userid')") or die(mysql_error()); //// ALL OTHER FIELDS ENDS } } Link to comment https://forums.phpfreaks.com/topic/171611-solved-_post-only-send-first-dynamic-field-to-db/ Share on other sites More sharing options...
StefanRSA Posted August 24, 2009 Author Share Posted August 24, 2009 Anybody? Link to comment https://forums.phpfreaks.com/topic/171611-solved-_post-only-send-first-dynamic-field-to-db/#findComment-904954 Share on other sites More sharing options...
StefanRSA Posted August 24, 2009 Author Share Posted August 24, 2009 SOLVED.... My second Query was cancelling the first... Just had to rename it... Link to comment https://forums.phpfreaks.com/topic/171611-solved-_post-only-send-first-dynamic-field-to-db/#findComment-905014 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.