1

How to store a html table data into MySQL database.

Sample Html code is given below. In original, there is about thousand form on the same page.

<thead>
<tr>
    <th> Id</th>
    <th>From area</th>
    <th>To area</th>
    <th>Basic price</th>
</tr>
</thead>   
<form action="basicprice.php" method="get" name="basicprice">
<tr>
    <td>4</td>
    <td class="static">Address 1</td>
    <td class="static">Airport 1</td>
    <td class="center"><input type="text" name="basicprice" value="54"></td>
    <td><input name="submit" type="submit" value="Save"></td>
</tr>                                     
</form>
<form action="basicprice.php" method="get" name="basicprice">
<tr>
    <td>4</td>
    <td class="static">Address 1</td>
    <td class="static">Airport 1</td>
    <td class="center"><input type="text" name="basicprice" value="54"></td>
    <td><input name="" type="submit" value="Save"></td>
</tr>                                      

I want create a database from these details. Need Help.

Thanks in advance

4
  • You wanna store the <form> structure in Database? Why? Commented Jan 6, 2017 at 9:09
  • you can use array please try reading array documnetaion if you are a starter. Commented Jan 6, 2017 at 9:10
  • no no. this is the html I have. I want store the value which is in td tags and textbox. I can't do it manually because there are thousands of same snippets are there @PraveenKumar Commented Jan 6, 2017 at 9:13
  • Is value is same for all it will keep on changing for every form..? Commented Jan 6, 2017 at 9:15

2 Answers 2

1

Use only one form and add input feild name as array[]

<form action="basicprice.php" method="get" name="basicprice">
<tr>
    <td>4</td>
    <td class="static">Address 1</td>
    <td class="static">Airport 1</td>
    <td class="center"><input type="text" name="basicprice[]" ></td>
    <td><input name="submit" type="submit" value="Save"></td>
</tr>                                     
</form>

In this array you will get all values no need to write forms again and again.

Sign up to request clarification or add additional context in comments.

Comments

1

Have a look on bellow link "PHP - Insert data from HTML table into MySQL database" might give you some idea on how to make insert query using array elements

Comments

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.