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:

http://test.ru/example.php?name=%D0%E0%E4%E8%E0%F2%EE%F0
&price=500 &izm=%D8%F2%F3%EA%E0 &id=4
&name=%CA%EE%ED%E4%E8%F6%E8%EE%ED%E5%F0
&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:

$name=$_GET['name'].

Only the last name is accepted 🙁


Answer 1

Pass an array into a get

HTML

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

PHP

<? 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

<?
if(isset($_GET['name'])){ 
$names=$_GET['name'];
$num=count($name);
for($i=0;$i<$num;$i++){echo $names[$i];}

}
//for example))
?>