scarezekiel Posted February 27, 2012 Share Posted February 27, 2012 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>  </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> Quote Link to comment https://forums.phpfreaks.com/topic/257848-need-tips/ Share on other sites More sharing options...
Pikachu2000 Posted February 27, 2012 Share Posted February 27, 2012 Here's your first tip: When posting code, enclose it within the forum's . . . BBCode tags. Quote Link to comment https://forums.phpfreaks.com/topic/257848-need-tips/#findComment-1321585 Share on other sites More sharing options...
scarezekiel Posted February 27, 2012 Author Share Posted February 27, 2012 okay..ill do it next time Quote Link to comment https://forums.phpfreaks.com/topic/257848-need-tips/#findComment-1321587 Share on other sites More sharing options...
scarezekiel Posted February 27, 2012 Author Share Posted February 27, 2012 so...can help me? Quote Link to comment https://forums.phpfreaks.com/topic/257848-need-tips/#findComment-1321622 Share on other sites More sharing options...
l0gic Posted February 27, 2012 Share Posted February 27, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/257848-need-tips/#findComment-1321808 Share on other sites More sharing options...
scarezekiel Posted February 28, 2012 Author Share Posted February 28, 2012 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"/> Quote Link to comment https://forums.phpfreaks.com/topic/257848-need-tips/#findComment-1321889 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.