I want to insert multiple rows in a database table, from an submit form. But not able to trouble shoot the problem in my code. Following is the code which is not inserting any row in the database.
<form action=test_insert.php method="post">
<table>
<?php for($i=0; $i<10; $i++)
{ ?>
<tr>
<td><input type="text" name="employee_id" value="0" size = "2" ></td>
<td><input type="text" name="task_no" value="0" size = "2" ></td>
<td><input type="text" name="discription" value="0" size = "2"></td>
<td><input type="text" name="mon" value="0" size = "2"></td>
<td><input type="text" name="tue" value="0" size = "2"></td>
<td><input type="text" name="wed" value="0" size = "2"></td>
<td><input type="text" name="thu" value="0" size = "2"></td>
<td><input type="text" name="fri" value="0" size = "2"></td>
<td><input type="text" name="sat" value="0" size = "2"></td>
<td><input type="text" name="sun" value="0" size = "2"></td>
<td><input type="text" name="total" value="0" size = "2"></td>
<td><input type="text" name="week_no" value="0" size = "2"></td>
</tr>
<?php } ?>
</table>
<input name="submit" value="Submit" type="submit">
</form>
<?php
$conn = pg_connect("host=localhost port=5432 dbname=**** user=postgres password=****");
$query = "insert into public.grid_data (employee_id, task_no, discription, mon, tue, wed, thu, fri, sat, sun, total, week_no)
Values
($employee_id,$task_no,$discription,$mon,$tue,$wed,$thu,$fri,$sat,$sun,$total,$week_no) ";
$res = pg_query($conn, $query) or die(pg_last_error());
if($res){echo("Record added for : $employee_id");}
?>
The 2 errors which I am gettin are. 1. undefined variable for all ( $employee_id, $task_no .....) and
2. Query failed: ERROR: syntax error at or near ","\nLINE 3: (,,,,,,,,,,,) \n ^
Many thanks in advance