0

i want to save the values in one array where have the following positions:

array[1] -> id_resp
array[2] -> corp_resp
array[3] -> date  
array[4] -> menuId
array[5] -> id
array[6] -> id_resp
array[7] -> corp_resp
array[8] -> date  
array[9] -> menuId
array[10] -> id
      .
      .

There you can see the var_dump is given in that page and the table where need to get the values.

enter image description here

There is what is in database and what we need to have correctely in database:

    id_resp     corp_resp        date         MenuId    id

    654           0.3          2016-11-25        6      28    <- inserted in database wrong.



 Correct need to be that to be the output in the database:

        654           0.3          2016-11-25        4      28 
        655           0.3          2016-11-25        5      28  
        656           0.35         2016-11-25        6      28 

That is the code after the option value submitted. There is given the wrong output like you can see in the top.

 $id_resp = (isset($_POST['id_resp']) ? $_POST['id_resp'] : '');
 $corp_resp = (isset($_POST['corp_resp']) ? $_POST['corp_resp'] : '');
 $id = $_SESSION['UtilizadorID'];
 $data = (isset($_POST['data']) ? $_POST['data'] : '');
 $menuId = $_SESSION['menuID'];

 var_dump ($menuId);

 mysql_query("INSERT INTO respostas 
                    (id_resp, corp_resp,id,data,menuId) 
             VALUES ('','" . $corp_resp . "','" . $id . "', NOW( ) , '$menuId')")  
    or die("Alguma coisa correu mal durante o registo. MySQL erro: ".mysql_error());
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • 1
    You say you want 3 rows created but you only attempt to create one row ???? – RiggsFolly Nov 25 '16 at 21:04
  • 2
    Every time you use [the `mysql_`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) database extension in new code **[a Kitten is strangled somewhere in the world](http://2.bp.blogspot.com/-zCT6jizimfI/UjJ5UTb_BeI/AAAAAAAACgg/AS6XCd6aNdg/s1600/luna_getting_strangled.jpg)** it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning the `PDO` or `mysqli` database extensions. [Start here](http://php.net/manual/en/book.pdo.php) – RiggsFolly Nov 25 '16 at 21:05
  • Welcome to SO. Please read [What topics can I ask about](http://stackoverflow.com/help/on-topic) and [How to ask a good question](http://stackoverflow.com/help/how-to-ask) And [the perfect question](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) – RiggsFolly Nov 25 '16 at 21:06
  • @RiggsFolly, yes and is wrongly that is inserted in the database. Is posible to define one array in that way? – Christophe Costa Nov 25 '16 at 21:17

0 Answers0