Jump to content

Best way to show a print/view page


cerebrus189

Recommended Posts

Hi all,

I've got a training database here that displays both supervisor and their employee's information regarding training classes. As an assignment, I must create a way for the supervisors view/print each employee's record as far as what is left to do for training.

 

What's the best way to accomplish this? Any ideas? I would like to have a print/view button with some plain text but it needs to be available for each employee from the supervisor's page so that each employee has a separate view window that pops open. I thought PHP might work for me since almost our whole website is done in PHP and this is how I'd pass the parameters. But I'm also thinking that javascript would be helpful for the actual print function.

 

As far as the code goes, this is a small snippet of the supervisor's employees code.

 

//get list of all of the supervisor's employees
	$query = "SELECT * FROM employees WHERE supervisor_id=" . $_SESSION['empNo'];
	$rs = mysql_query($query, $conn);
	$numEmployees = mysql_num_rows($rs);
	while ($numEmployees != 0) {
	  echo "<p align=\"left\" class=\"style11\"><span class=\"style2 style4\">Your Employee's Classes</span></p>";
	  echo "<p align=\"left\" class=\"style11\">";
	  for ($b = 0; $b < $numEmployees; $b++){
	     $result = mysql_fetch_array($rs);

	     //grab the classes that are required
	     $innerquery="SELECT course, date_last_taken, certification FROM course_completions WHERE employee_id='" . $result['employee_id'] . "' order by date_last_taken asc"; 
		 $innerrs = mysql_query($innerquery, $conn);
		 $numcourses = mysql_num_rows($innerrs);
		 echo "<span class=\"style2 style4\">" .$result['last_name'] . ", " . $result['first_name'] . "</span><br />";
		 echo "<span style=\"color:#FFFF00\">Required Classes</span><br />";
		 echo "<table width=100% class=\"style11\">";
		 echo "<th align=\"left\">Course</th><th align=\"left\">Complete By</th><th align=\"left\">Action</th>";
		 while ($innerresults = mysql_fetch_array($innerrs))
		 {
	       echo "<tr>";
	       echo "<td width=33%>";
	       echo $innerresults["course"];
	       echo "</td><td width=10%>";
	       echo date("m-d-Y",strtotime($innerresults["date_last_taken"]));
	       echo "</td><td width=57%>";
	       echo "<a href=\"employeeregister.php?" . SID . "&classname=" . $innerresults["course"] . "&employid=" . $result['employee_id'] . "\">Register</a>";
	       echo "</td></tr>";		  	  
	     }
	     echo "</table><br />";

		 //grab the classes that are enrolled
		 $innerquery = "SELECT course, course_enrollment_id, employee_id, status, date FROM course_enrollment WHERE employee_id='" . $result['employee_id'] . "' order by date asc";
		 $innerrs = mysql_query($innerquery, $conn);
		 $numcourses = mysql_num_rows($innerrs);
		 echo "<span style=\"color:#FFFF00\"> Registered Classes</span>";
		 echo "<table width=100% class=\"style11\">";
		 echo "<th align=\"left\"><b>Class Name</b></th><th align=\"left\">Class Date</th><th align=\"left\">Status</th><th align=\"left\">Select Cancel to Dis-Enroll from a Class</th>";
		 if ($numcourses ==0) {
		   echo "<tr><td width=33%>No classes enrolled</td><td width=10%> </td><td width=10%> </td></tr>";
		 }
		 while ($innerresults = mysql_fetch_array($innerrs))
		 {
		   echo "<tr>";
		   echo "<td width=33%>";
		   echo $innerresults["course"];
		   echo "</td><td width=10%>";
   		       if ($innerresults["date"] == "0000-00-00") {
	         echo "CANCELED";
		     echo "</td><td width=10%> </td>
			 <td width=47%> </td></tr>";
	       }
	       else {
	         echo  date("m-d-Y",strtotime($innerresults["date"]));
			 echo "<td width=10%>". $innerresults['status'] . "</td>";
		     echo "</td><td width=47%><a href=\"cancelclass.php?" . SID . "&classid=" . $innerresults["course_enrollment_id"] . "&classname=" . $innerresults["course"] ."&classdate=" . $innerresults["date"] . "\">Cancel</a></td></tr>";
	       }

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

		   
	  }
	}

 

 

I'm thinking the code would go somewhere in here as far as the button is concerned so that maybe it can simply be echoed based on being in a div tag or other html structure.

Link to comment
https://forums.phpfreaks.com/topic/207759-best-way-to-show-a-printview-page/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.