How to pass form data to the database and then successfully reproduce it?

PHP language. You need to write data to a table.

There is a form. My data is transmitted via GET.
After pressing the GETbutton, a string like this is transmitted:
&price=500 &izm=%D8%F2%F3%EA%E0 &id=4
&price=14000 &izm=%D8%F2%F3%EA%E0
&id=3 &name=%D3%E3%EE%EB &price=5656
&izm=%E4%F0 &id=7 &send=%CE%EA

I have 4 items in the table. The user must first make changes to the database lines through input, and then by pressing the submitbutton, write the changes to the database.

Unable to overwrite all lines. Only the last one is overwritten. I guess that the process needs to be done through while, but I don’t understand how to do it :-(.

In the handler, for example, I accept a namevariable like this:


Only the last name is accepted 🙁

Answer 1

Pass an array into a get


<input type="text" name="val[1][id]" />
<input type="text" name="val[1][name]" />
<input type="text" name="val[1][izm]" />


<? if (!empty($_GET['val'])) foreach ($_GET['val'] as $val) print_r($val); ?>

Everything you received will be visible here.

Answer 2

usually if there are elements with the same name, then they write like this

<input type='text' name='name[]'>
<input type='text' name='name[]'>
<input type='text' name='name[]'>

that is, we denote them as an array, and we accept them in this way

for($i=0;$i<$num;$i++){echo $names[$i];}

//for example))