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 } } Quote Link to comment Share on other sites More sharing options...
StefanRSA Posted August 24, 2009 Author Share Posted August 24, 2009 Anybody? Quote Link to comment 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... 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.