sashiksu 0 Light Poster

heY guys :) recently I'm on web project which I use MySQL, bootstrap, PHP and Javascript. For this I have generated successfully dynamical forms using PHP. I'm using mysqli commands. I used dynamic forms if it not used I have to create hundred of html pages. So by doing this I could reduce everything to one page.

Right so far I'm facing problem 'inserting data to through this dynamic forms'. Exactly I know as I use generate dynamic forms I need dynamic generating code to insert data to database. If not as I mentioned above again I have to create hundred codes for this. Lets move to problem, I mentioned above info to get well idea about my problem. :)

I need to insert data to this kind of data table.


Let's assume my dynamic code source is like below.


        <form method="POST">

            <div class="form-group">
            <input type="hidden" value="10">
                <label for="Mileage">Mileage</label>
                <input type="text" class="form-control" name="Mileage">

            <div class="form-group">
            <input type="hidden" value="16">
                <label for="Body_Type">Body Type</label>
                <select class="form-control" name="Body_Type">
                    <option>Convertible</option><option>Coupe / Sports</option><option>Hatchback</option><option>MPV</option><option>Saloon</option><option>Station Wagon</option><option>SUV / 4x4</option> 

            <div class="form-check-inline">
            <input type="hidden" value="18">
                <label for="Fuel_Type">Fuel Type</label>
                <label class="form-check-label">

                    <input type="checkbox" class="form-check-input" name="Fuel_Type" value="">Diesel
                    <input type="checkbox" class="form-check-input" name="Fuel_Type" value="">Petrol
                    <input type="checkbox" class="form-check-input" name="Fuel_Type" value="">CNG
                    <input type="checkbox" class="form-check-input" name="Fuel_Type" value="">Other Fuel

            <div class="form-group">
                <button type="submit" class="btn btn-outline-success" name="insertCAR">Finish</button>

I used bootstrap. That's why how my code get lengthy. =D So my form doesn't have images. Only text values.

But there are different input types I used. Those everything generated by dynamic. When I choose different category this form structure will be change and no of input types also maybe different than this. I want to include PHP insert code with this page. So whenever this page load after user select category form code and data insert PHP code also generate dynamically according to category.

Inserting code will be called by form button. This button's name also dynamic. But here is the main point.

Text box value should be entered to table as one record. As same radio, check, textarea or whatever value should be enter as one row. Again I'll mention here my table for you guy' easy.


Since Rec_ID will increment when we entering it to the db we don't have to deal with it. Ad_ID also I can pass to insert query using $_GET(variable) since it loaded with URL. Attribute_ID I'm planing to get it to input type hidden. So lastly VALUE will be set according to user selection. I can get no of elements in form using mysqli_num_row command. So I know I should repeat insert query equaly to above no of elements. But because of I'm new to PHP I can't figure it myself to build this code.So I need help from you.

When you seeing above you could identify what I need is, Insert one div's hidden value with input type value (text,radio,checkbox) and others as per row.

I need you guys help for code. I'm really appreciate it right now !

Thank You !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.