Hello Abu please help.
I have a table (courses) with a list of all courses done for a specific diploma program, I have another table called courses_on_offer, my aim is to get/select several courses from table (courses) and click a button (Add Courses) to insert all selected courses into another table (courses_on_offer) and set common values for inserted rows which include session_id, start_date, end_date.
I tried with excel blank rows
function update_data($data)
{
$grid = new jqgrid();
// If bulk operation is requested, (add-rows default otherwise)
if ($data[“params”][“bulk”] == “add-rows”)
{
for($i=0;$i<$rows;$i++)
$grid->execute_query(“INSERT INTO courses_on_offer (id,course_code,course_name) VALUES (”,'{$data[“params”][“course_code”]}’,'{$data[“params”][“course_name”]}’)”);
die;
}
course_code and course_name are blank when I try the code above
Please help me.
I’d suggest to use different approach. Refer bulk edit demos/editing/bulk-edit.php
Select row and perform bulk operation, like in demo (email rows) or similar. And in callback, you will receive IDs of the selected rows of course table.
There you can runĀ $grid->execute_query for INSERT INTO table SELECT query.
INSERT INTO table2 (column1, column2, column3, …)
SELECT column1, column2, column3, …
FROM table1
You can use common values in sql as well as fixed string.