Jump to content

need tips


scarezekiel

Recommended Posts

so i want to create a new page that will display only my data..on that page user will only see the leave details(marked in red line) and able to print it..which code should i use..so this is my code from the main page

 

 

 

 

 

 

 

<div id="box" valign="top">

                <h3> <strong>Leave Application Details</strong> &nbsp</h3>

<br><br>

<FORM name ="printbutton" method="post" align="left" action="index.php?view=print">

 <Input type = "Submit" Name = "Submit1" Class="button" VALUE = "Print Leave Details">

                <table width="80%" align="center" >

<thead>

<tr>

<th width="700px" align="left">Name</a></th>

                           

<th width="500px" align="center"></a>Application</th>

 

<th width="500px" align="center"></a>Date</th>

                         

<th width="500x" align="right"></a>Reason</th>

</tr>

</thead>

<tbody>

<?

/*echo "branch:".$branch.'<br />';

echo "leavemonth:".$leavemonth.'<br />';

echo "leaveyear:".$leaveyear.'<br />';*/

//--------------------------------------------------

if ($leavemonth =='' ||  $leaveyear =='' || $branch == '') {

// one value missing, so don't display

}

else

{

// start display data

$rs = mysql_query( " call vwleavereport('$leavemonth', '$leaveyear', $branchid, 0);");

$query="SELECT *,

MONTH(tblleaveapplication.DateFrom) as DFMonth,

MONTH(tblleaveapplication.DateTo) as DTMonth,

YEAR(tblleaveapplication.DateFrom) as DFYear

FROM `tblleaveapplication`

LEFT JOIN `tblemployee`

ON tblleaveapplication.employeeid = tblemployee.id

WHERE WorkGroupID = '".$branch."'

AND (

(MONTH(tblleaveapplication.DateFrom)=".$leavemonth." AND YEAR(tblleaveapplication.DateFrom)=".$leaveyear.")

OR

(MONTH(tblleaveapplication.DateTo)=".$leavemonth." AND YEAR(tblleaveapplication.DateFrom)=".$leaveyear.")

)

";

 

$result = mysql_query($query);

while($row=mysql_fetch_array($result))

{

echo '<tr>';

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

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

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

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

echo '</tr>';

}

 

}

?>

 

</table>

post-131669-13482403268538_thumb.jpg

Link to comment
https://forums.phpfreaks.com/topic/257848-need-tips/
Share on other sites

I'm a little confused, but I'm pretty sure the code you're looking for is pretty much exactly what you have pasted in your first post?

 

It would need a bit of tweaking, but from what you've provided there that's about as much as I can tell you.

Link to comment
https://forums.phpfreaks.com/topic/257848-need-tips/#findComment-1321808
Share on other sites

actually what i asked was the code how to pass the data to another page, so that i will be able to print it.

 

so i solved it anyway

 

here's my solution

 

and a photo of it

 

 

<?
session_start();
if(!isset($_SESSION['administrator'])){
header("location:../login.php");
}
include ("../config.php");
?>
<table width="80%" align="center" >
					<thead> 
<tr>
<th width="700px" align="left">Name</a></th>
                            	
<th width="500px" align="center"></a>Application</th>

<th width="500px" align="center"></a>Date</th>
                           
<th width="500x" align="left"></a>Reason</th>
</tr>
</thead>
<tbody>
<?
$branch=$_POST['branch'];
$leavemonth=$_POST['leavemonth'];
$leaveyear=$_POST['leaveyear'];

/*echo "branch:".$branch.'<br />';
echo "leavemonth:".$leavemonth.'<br />';
echo "leaveyear:".$leaveyear.'<br />';*/
//--------------------------------------------------
if ($leavemonth =='' ||  $leaveyear =='' || $branch == '') {
	// one value missing, so don't display		
}
else
{

	// start display data
	$rs = mysql_query( " call vwleavereport('$leavemonth', '$leaveyear', $branchid, 0);");
	$query="SELECT *, 
			MONTH(tblleaveapplication.DateFrom) as DFMonth,
			MONTH(tblleaveapplication.DateTo) as DTMonth,
			YEAR(tblleaveapplication.DateFrom) as DFYear
			FROM `tblleaveapplication`
			LEFT JOIN `tblemployee`
			ON tblleaveapplication.employeeid = tblemployee.id
			WHERE WorkGroupID = '".$branch."'				
			AND (
			(MONTH(tblleaveapplication.DateFrom)=".$leavemonth." AND YEAR(tblleaveapplication.DateFrom)=".$leaveyear.")
			OR
			(MONTH(tblleaveapplication.DateTo)=".$leavemonth." AND YEAR(tblleaveapplication.DateFrom)=".$leaveyear.")
			)
			";

	$result = mysql_query($query);
	while($row=mysql_fetch_array($result))
	{
		echo '<tr>';
			echo '<td>'.$row['EmployeeName'].'</td>';
			echo '<td align="center">'.$row['DateFrom'].'</td>';
			echo '<td align="center">'.$row['DateTo'].'</td>';
			echo '<td>'.$row['Purpose'].'</td>';				
		echo '</tr>';			
	}

}
?>
<input type="button" onClick="window.print()" value="Print This Page"/>

 

 

post-131669-13482403269505_thumb.jpg

post-131669-13482403269805_thumb.jpg

Link to comment
https://forums.phpfreaks.com/topic/257848-need-tips/#findComment-1321889
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.