onay kutusu aracılığıyla insert

0 Cevap php

Ben onay kutusu aracılığıyla eklemek çalışıyorum, ancak yalnızca bir kayıt, ben 10 kayıtları var tabloda varsayalım kaydeder, sadece 10 tane kaydeder. Her için bir sorun olduğunu düşünüyorum. Herkes bana yardımcı olabilir misiniz?

<form id="assign" name="assign" method="post" action="assign_individual_exec.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"> Start Date</td>
<td><input type="date" name="sdate" ></td><td><script language="JavaScript">
    new tcal ({
        'formname': 'assign',

        'controlname': 'sdate'
    });

    </script></td></tr>



<?php

include('member_table.php');
?>

    <tr>
      <div align="right"class="lien">

        <td><input type="submit" name="individual" value="assign to individual"  />

member_table.php

<?php


$member_id = $_SESSION['SESS_MEMBER_ID'];

   $first= mysql_query("select userid from dept_user where lead_id=$member_id");

echo "<table border='1' id=coursetable class=coursetable>
<tr>
<th>first name</th>
<th>last name</th>
<th>dept name</th>
<th>title</th>
<th>rolename</th>
<th>leader first name</th>
<th>leader last name</th>
</tr>";

 while($res = mysql_fetch_array($first)){

$user1 = $res['userid'];


$display= mysql_query("Select user.firstname, user.lastname, department.dept_name, job_title.title, role.rolename, user.userid From user Inner Join  dept_user On user.userid = dept_user.userid Inner Join  department On department.dept_id = dept_user.dept_id Inner Join  job_title On job_title.title_id = user.titleid Inner Join  role On role.roleid = user.roleid Where user.userid = $user1 "); 




$leader = mysql_query("Select firstname , lastname From user Inner Join  dept_user On user.userid = dept_user.lead_id  Where dept_user.lead_id =$member_id");

while(($row1 = mysql_fetch_array($display)) and ($lead = mysql_fetch_array($leader)))

  {

  echo "<tr>";
  echo "<td>" . $row1['firstname'] . "</td>";
  echo "<td>" . $row1['lastname'] . "</td>";
  echo "<td>" . $row1['dept_name'] . "</td>";
  echo "<td>" . $row1['title'] . "</td>";
echo "<td>"  . $row1['rolename'] . "</td>";
echo "<td>"  . $lead['firstname'] ."</td>";
echo "<td>"  . $lead['lastname'] . "</td>";
echo  "<td>" .'<input type="checkbox" name="userid" value='.$row1['userid'].'>'."</td>";
  echo "</tr>";

  }

 if ($user1 !== 0){

 $second = mysql_query("select userid from dept_user where lead_id=$user1");

 while($res1 = mysql_fetch_array($second)){

 $user2= $res1['userid'];



if($user2 !==0) {



   $display2 = mysql_query("Select user.firstname, user.lastname, department.dept_name, job_title.title, role.rolename, user.userid From user Inner Join  dept_user On user.userid = dept_user.userid Inner Join  department On department.dept_id = dept_user.dept_id Inner Join  job_title On job_title.title_id = user.titleid Inner Join  role On role.roleid = user.roleid Where user.userid = $user2 "); 


   $leader1= mysql_query("Select firstname , lastname From user Inner Join  dept_user On user.userid = dept_user.lead_id  Where dept_user.lead_id = $user1");

while(($res1 = mysql_fetch_array($display2))  and ($lead1 = mysql_fetch_array($leader1)))

  {
  echo "<tr>";
  echo "<td>" . $res1['firstname'] . "</td>";
  echo "<td>" . $res1['lastname'] . "</td>";
  echo "<td>" . $res1['dept_name'] . "</td>";
  echo "<td>" . $res1['title'] . "</td>";
echo "<td>"  . $res1['rolename'] . "</td>";
echo "<td>"  . $lead1['firstname'] . "</td>";
echo "<td>"  . $lead1['lastname'] . "</td>";
echo  "<td>" .'<input type="checkbox" name="userid" value='.$res1['userid'].'>'."</td>";
  echo "</tr>";
  }

    if ($user2 !== 0){

    $third = mysql_query("select userid from dept_user where lead_id=$user2");

while($res2 = mysql_fetch_array($third)) {

 $user3 = $res2['userid'];

 echo "<br/>";

 if ($user3 !== 0){


 $display3 = mysql_query("Select user.firstname, user.lastname, department.dept_name, job_title.title, role.rolename, user.userid From user Inner Join  dept_user On user.userid = dept_user.userid Inner Join  department On department.dept_id = dept_user.dept_id Inner Join  job_title On job_title.title_id = user.titleid Inner Join  role On role.roleid = user.roleid Where user.userid = $user3"); 

    $leader2 = mysql_query("Select firstname, lastname From user Inner Join  dept_user On user.userid = dept_user.lead_id  Where dept_user.lead_id = $user2");

while(($row = mysql_fetch_array($display3)) and ($lead2 = mysql_fetch_array($leader2)))


  {

  echo "<tr>";
  echo "<td>" . $row['firstname'] . "</td>";
  echo "<td>" . $row['lastname'] . "</td>";
  echo "<td>" . $row['dept_name'] . "</td>";
  echo "<td>" . $row['title'] . "</td>";
echo "<td>"  . $row['rolename'] . "</td>";
echo "<td>"  . $lead2['firstname'] . "</td>";
echo "<td>"  . $lead2['lastname'] . "</td>";
echo  "<td>" .'<input type="checkbox" name="userid" value='.$row['userid'].'>'."</td>";
  echo "</tr>";
  }

}
    }
}
}
}

}
}
echo"</table>";
?>

assign_training_exec.php

<?php
include('include.php'); 
    include('config.php');
    require_once('auth.php');
    session_start();


$user[]= clean($_POST['userid']);
    $name = clean($_POST['name']);
    $date = clean($_POST['sdate']);
$month = substr($date, 0 ,2);
 $day= substr($date, 3, -5); 
$yr = substr($date, 6); 
$dash = "-";
$date_str = ($yr.$dash.$month.$dash.$day);


$m_name = $_SESSION['SESS_FIRST_NAME'];

   foreach ($user as $user_array){
    $insert_query = "INSERT INTO course_detail(userid, course_id, date_assign, owner) VALUES('$user_array','$name','$date_str', '$m_name')"; 
    $insert = mysql_query($insert_query); 
}



    if($insert_buffer) {

                exit();
    }else {
        die("Query failed");
    }

?>

0 Cevap