0

Hi i want to add multiple rows dynamically of my form with same fields but different form field name (e.g. city1, city2, city3,... college1,college2,college3...) and then all data into mysql

I tried so my search but nothing works for me here is my code please help me in this

<div class="form_student_add">
                    <table class="dd" width="100%" id="data">
                    <tr>
                    <td>City</td>
                    <td>College</td>
                    <td>Name</td>
                    </tr>

                    <tr>
                    <td>
                    <select name="city" id="city">
                    <option selected="selected" value="0">--Select City--</option>
                    <?php                           
                        $sql=mysql_query("select * from tblcities");
                            while($row=mysql_fetch_array($sql))
                                {
                                    $id=$row['city_id'];
                                    $data=$row['city_name'];
                                    echo '<option value="'.$id.'">'.$data.'</option>';
                                } 
                    ?>
                    </select>
                    </td>

                    <td>
                    <select name="college" id="college">
                    <option selected="selected" value="0">--Select College--</option>
                    <?php                           
                        $sql=mysql_query("select * from tblcollege");
                            while($row=mysql_fetch_array($sql))
                                {
                                    $id=$row['college_id'];
                                    $data=$row['college_name'];
                                    echo '<option value="'.$id.'">'.$data.'</option>';
                                } 
                    ?>
                    </select></td>

                    <td><input name="full_name" type="text" placeholder="e.g. John Smith" /></td>
                    </tr>
                    </table> 

                    <div class="form_btn_videos">
                    <input type="button" id="id="addTableRow"" name="addnew" value="Add New Part" />
                    </div>
                </div>
2
  • "but nothing works" is not a valid problem description. Tell us what this code produces, and what you expect that it produces. Commented Nov 23, 2014 at 13:36
  • I followed these instructions available on this link: stackoverflow.com/questions/2145012/… but Iam only able to add more filed but js dont load the php populated drop downs as you can see i have 3 drop downss so I am only able to create a html coded drop down but i want to populate drop down through mysql please check this one stackoverflow.com/a/13741715/3606257 Commented Nov 23, 2014 at 13:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.