Jump to content

arrays in mysql


claro

Recommended Posts

is  it possible to save it this way? I found no errors but there are also no effect in my db. help me guys! thank you. 

 

"while ($row = mysql_fetch_array($query))

  {

 

 

  echo "<tr>";

  echo  '<td><input type="hidden" name="se_Id['.$i.']">'.$row['se_Id'].'</td>';

  echo '<td><input type="hidden" name="user_Id['.$i.']">'.$row['user_Id'].'</td>';

  echo '<td><input type="hidden" name="course_Id['.$i.']">'.$row['course_Id'].'</td>';

  echo '<td><input type="hidden" name="ap['.$i.']">'.$row['ap_Id'].'</td>';

  echo "<td>". $row['user_Fname']."</td>";

  echo "<td>". $row['user_Lname']."</td>";

  echo "<td></td>";

  echo "<td></td>";

  echo "<td>".$row['se_Yearlevel']."</td>";

  echo "<td></td>";

  echo "<td></td>";

  echo "<td></td>";

  echo "<td>    <input type='checkbox' id='checkbox".$i."' value ='checked' onclick='checkbox_disabled(\"checkbox".$i."\",\"textbox".$i."\",\"checkbox".$i."2\");'></td>";

  echo "<td><input type='checkbox' id='checkbox".$i."2'>";

  echo "  <input type='text' id='textbox".$i."'></td>";

  echo "</tr>";

  $i++;

 

  }

  }

else

{

echo "No students enrolled";

}

  echo "</form>";

 

echo "</table>";

echo "<br></br>";

echo "  <input type='submit' name = 'submit' value='Submit'>";

 

?>

 

<?php

  if (isset($_POST['submit']))

  {

      foreach ($_POST['user_Id'] as $key => $user_Id)

      {

        $se_Id = $_POST['se_Id'][$key];

        $status = $_POST['status'][$key];

        $course = $_POST['course'][$key];

$officeid [$key];

        $ap = $_POST['ap'][$key];

        mysql_query("INSERT tbl_data (user_Id,se_Id,office_Id,course_id,ap_Id,Status)

VALUES ('$user_Id','$se_Id','$officeid','$course','$ap','$status')")

        or die(mysql_error());

// echo "<meta http-equiv=\"refresh\"content=\"0;URL=offcourse_view.php\">";

echo "congrats";

              }

 

}

?>"

 

Link to comment
Share on other sites

<?php
$course1 = $_POST['course'];
$courses = mysql_query ("SELECT course_Title FROM tbl_course WHERE course_Id = '$course1'")
or die (mysql_error());
$result = mysql_fetch_array($courses);
$course = $result['course_Title'];

$program = $_POST['program'];

echo "<br></br>";
echo "<td><b>  Course:       <i>".$course."</i></b></td><br/>";
echo "<td><b>  Program:    <i>".$program." "."Class</b></i></td>";
echo "<br></br>";

echo "<form action = '#' method = 'POST'>";
echo "<table>";

$query = mysql_query("SELECT * FROM tbl_studenroll, tbl_user WHERE user_Level = 'Student' 
				AND course_Id = '$course1' 
				AND user_Program = '$program' 
				AND tbl_user.id = tbl_studenroll.user_Id
				ORDER BY se_Yearlevel DESC ")
		or die (mysql_error());

   if  (mysql_num_rows($query)>0)
{   

   echo "<tr>";
   echo "<td></td><td></td><td></td><td></td><th>Student's</th><th>Name</th><td></td><td></td><th>Year</th><td></td><td></td><td></td><th>Cleared</th><th>Not Cleared</th>";

   echo "<tr/>";
   while ($row = mysql_fetch_array($query))
   {
   echo "<tr>";
   echo  '<td><input type="hidden" name="se_Id" value='.$row['se_Id'].'></td>';
   echo '<td><input type="hidden" name="user_Id" value='.$row['user_Id'].'></td>';
   //echo '<td><input type="hidden" name="course_Id" value='.$row['course_Id'].'></td>';
   echo '<td><input type="hidden" name="ap" value='.$row['ap_Id'].'></td>';
   echo "<td>". $row['user_Fname']."</td>";
   echo "<td>". $row['user_Lname']."</td>";
   echo "<td></td>";
   echo "<td></td>";
   echo "<td>".$row['se_Yearlevel']."</td>";
   echo "<td></td>";
   echo "<td></td>";	
   echo "<td></td>";
   echo "<td>    <input type='checkbox' id='checkbox' value ='checked' onclick='checkbox_disabled(\"checkbox\",\"textbox\",\"checkbox2\");'></td>";
   echo "<td><input type='checkbox' id='checkbox".$i."2'>";
   echo "  <input type='text' id='textbox'></td>";
   echo "</tr>";
   

   }
  }
else
{
echo "No students enrolled";
}
   echo "</form>";
   
echo "</table>";
echo "<br></br>";
echo "  <input type='submit' name = 'submit' value='Submit'>";

  if (isset($_POST['submit']))
   {
      foreach ($_POST['user_Id'] as $key => $user_Id)
      { 
         $se_Id = $_POST['se_Id'][$key]; 
         $status = $_POST['status'][$key];
         $course = $_POST['course'][$key];
	 $officeid [$key];
         $ap = $_POST['ap'][$key];

	 echo $se_Id;
	 echo $status;
	 echo $course;
	 echo $officeid;
	 echo $ap;



         mysql_query("INSERT tbl_data (user_Id,se_Id,office_Id,course_id,ap_Id,Status)
				VALUES ('$user_Id','$se_Id','$officeid','$course1','$ap','$status')")
         or die(mysql_error());
	// echo "<meta http-equiv=\"refresh\"content=\"0;URL=offcourse_view.php\">";
echo "congrats";
              }


		}		
	?>


 

I did it already. then?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.