Hello, i'm trying to insert multiplle values into a table.. but it is being stored o in the table.. i've been trying while loop but still no progress.. the system search for user related to its specefic staff concern and then assign a course..
<form id="assign" name="assign" method="post" action="assign_training.php">
<tr><td class="style3">Select course name:</td>
<td><select name="name" class="principal2"><?php select_coursename(); ?></select></td></tr>
<tr>
<td class="style3">Select Department:</td>
<td><select name="dept" class="principal2"><?php select_dept(); ?></select></td>
</tr>
<tr><td class="style3"> Start Date</td>
<td><input type="date" name="sdate"></td></tr>
<tr><td class="style3"> End Date</td>
<td><input type="date" name="edate"></td></tr>
<tr>
<div align="right"class="lien">
<td><input type="submit" name="submit" value="assign to department" />
<td><input type="submit" name="submit" value="assign to individual" />
</div></td>
</tr></form></table>
assigntraining.php
<?php
include('include.php');
include('config.php');
require_once('auth.php');
session_start();
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
//Sanitize the POST values
$name = clean($_POST['name']);
$dept= clean($_POST['dept']);
$date = clean($_POST['sdate']);
$edate = clean($_POST['edate']);
//Input Validations
if($name == '') {
$errmsg_arr[] = 'Select Course Name';
$errflag = true;
}
if($dept == '') {
$errmsg_arr[] = 'Select Department';
$errflag = true;
}
if($date == '') {
$errmsg_arr[] = 'Enter assign date';
$errflag = true;
}
/*
//If there are input validations, redirect back to the registration form
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: register-form.php");
exit();
}
*/
$m_name = $_SESSION['SESS_FIRST_NAME'];
$r = mysql_query("select userid from dept_user where dept_id=$dept LIMIT 0, 30 ");
{
$qry = "INSERT INTO course_detail(userid, course_id, date_assign, expected_end_date, owner) VALUES('[$r]','$name','$sdate', '$edate', '$m_name')" ;
}$result = @mysql_query($qry);
//Check whether the query was successful or not
if($result) {
header("location: assigntraining.php");
exit();
}else {
die("Query failed");
}
?>