PHP language. It is necessary to write data to the table.

There is a form. My data is transmitted via GET . After pressing the GET button, the following string is passed:

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 strings via input , and then, by pressing the submit button, write the changes to the database.

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

In the handler, for example, I accept the name variable as follows:

 $name=$_GET['name']. 

Only the last name is accepted: (

    2 answers 2

    Pass an array to 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); ?> 

    Here you will see everything that you received.

    • @barakh, if the answer helped, click the checkbox to the left of the question (accept the answer). It’s undesirable to spend your respect points) - Sh4dow

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

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

    Ie we designate them as an array, well, so we take

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

    } // for example))?>