Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a rendered table from a mysql database on my web page. after applying some css properties to it, i want to b able to print that portion where the table is..
here is the php an html code for the portion I'll like to print on a portrait paper orientation

HTML
<div id="content">
       
    <div><span style="font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 13pt; color: #8b0000">STUDENTS' ACADEMIC PROFILE</span></div>
      
      <hr  style="color:#900;"/>
      
  <div class="rsltPg">
      <p>
  <div >    <div class="titleAmin">
           <input  name="unimaidLogo" type="image" class="AdminImg" src="../Images/logoanim.gif" alt="unimaidLogo" align="middle" width="45" height="80" hspace="16" vspace="13" />
         
<p style="font-size:16px">UNIVERSITY OF MAIDUGURI </p>
         <p style="font-size:10px">(Faculty of Engineering)</p>
         <p>DEPARTMENT OF CHEMICAL ENGINEERING</p>

       </div>

      <!--Start University news-->
  </div>
  
<div>
        <div> 
          <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="GET" name="stuRequest" id="stuRequest" >
            <p>
      <label for="sessionID" style="font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-weight:bold; font-size: 10pt; color: #8b0000">Select Session:</label>
      <select name="sessionID" id="sessionID">
        <?php
do {  
?>
        <option value="<?php echo $row_rsAcadsession['id']?>"><?php echo $row_rsAcadsession['sessionID']?></option>
        <?php
} while ($row_rsAcadsession = mysql_fetch_assoc($rsAcadsession));
  $rows = mysql_num_rows($rsAcadsession);
  if($rows > 0) {
      mysql_data_seek($rsAcadsession, 0);
	  $row_rsAcadsession = mysql_fetch_assoc($rsAcadsession);
  }
?>
      </select> 
      /
            <select name="semesterID">
            <option value="1">1st Semester</option>
            <option value="2">2nd Semester</option>
          </select>
          <?php if(isset($_SESSION['studentID']))
		  {
		  ?>
          <p style="padding-removed40px"><input name="chkResults" type="submit" id="chkResults" value="Load Results"></p>
      </p></form>
     <?php if(isset($_GET['chkResults'])) {  ?> <p><label for="stuName">Student Name: </label>
        <?php echo $row_rsStursltname['Name']; ?> , <?php echo $row_rsStursltname['lastName']; ?></p>
      <p><label for="stuID">Student ID: </label><?php echo $_SESSION['studentID'] ?>
</p>
      <p><label for="stuSession">Session: </label>
        <?php echo $row_rsStursltYr['sessionID']; ?>      </p>
      <?php if ($totalRows_rsVwsessrsltdet !=0) {?>    
          <table align="center">
  <caption><p>B. Eng.(Hons) Chemical Engineering</p>
<?php echo $row_rsVwsessrsltdet['levelID']; ?> Level <?php echo $row_rsStursltsem['semesterName']; ?> ,<?php echo $row_rsStursltYr['sessionID']; ?>session
</caption>

    <tr>
      <th width="15%" scope="col">Course code</th>
      <th width="41%" scope="col">Course title</th>
      <th width="20%" scope="col"> Unit</th>
      <th width="24%" scope="col">Marks</th>
      <th width="24%" scope="col">Grade</th>
      <th width="24%" scope="col">product</th>
    </tr>
    <?php do { ?>
      <tr class="alt">
        <td><a><?php echo $row_rsVwsessrsltdet['courseID']; ?></a></td>
        <td><?php echo $row_rsVwsessrsltdet['courseDescription']; ?></td>
        <td><?php echo $row_rsVwsessrsltdet['courseUnit']; ?></td>
        <td><?php echo $row_rsVwsessrsltdet['Marks']; ?></td>
        <td><?php echo $row_rsVwsessrsltdet['Grade']; ?></td>
        <td><?php echo $row_rsVwsessrsltdet['GPP']; ?></td>
      </tr>
      <?php } while ($row_rsVwsessrsltdet = mysql_fetch_assoc($rsVwsessrsltdet)); ?>
          </table> 
        
<br /> 
     
        <?php
		
		while($row=mysql_fetch_array($rsChkarray,MYSQL_BOTH))
{

#calculate the results for each academic semester
mysql_select_db($database_connChePortal, $connChePortal);
$cal_Cumm= "SELECT SUM(vwr.courseUnit) cummUnit, SUM(vwr.GPP) cummGPP
			FROM vw_result vwr
			WHERE vwr.Grade NOT IN ('F')
			AND vwr.id=".$row[0]."
			AND vwr.semesterID=".$row[1].";";
			
$results=mysql_query($cal_Cumm, $connChePortal) or die(mysql_error());
$row_calCumm=mysql_fetch_assoc($results);


#declare the results into variables
$units= $row_calCumm['cummUnit'];
$gpp=$row_calCumm['cummGPP'];

$semesterGPA=($gpp/$units);

#cummulative results
#$cUnit=0;
$cUnit +=$units;
#$cGpp=0;
$cGpp +=$gpp;
$cGpa= ($cGpp/$cUnit);

#echo "</br>";
#print results
if ($row[1]==$_GET['semesterID']){

echo "<p><label for='cumUnit'>
        Cummulative Unit:</label>".$cUnit."</p>";
echo "<p><label for='cumPrdt'>
        Cummulative GPP:</label>".$cGpp."</p>";
echo "<p><label for='cumGpa'>
        Cummulative GPA:</label>".$cGpa."</p>";

}
#check URL variable for the result request	
if(($row[0]==$_GET['sessionID']) &&($row[1]==$_GET['semesterID']))  break;

}
   ?>
        
        
        
  <?php } else echo "No result for ".$row_rsStursltYr['sessionID']." session"; ?> 
  <?php } ?>
  </br>
  <?php } else echo "<p>No student to view result profile</p>"; ?>
  
 
        </div>
      
        
        
      </div>
      <!--Start news-->
  </div>





</div>


PS: recommended resourses also required for mi to learn javascript well.
Thanks
Posted
Comments
Mohibur Rashid 15-May-13 20:54pm    
It depends on which part do you want to show or hide.

whatever the logic you have to hide or show a specific part. it can be done with javascript or in php. but depends on your requirement
Sergey Alexandrovich Kryukov 15-May-13 23:28pm    
One civilized way is using CSS @media feature. Please see my answer.
—SA

1 solution

Please see my recent answer: How to print div in asp web page in windows xp?[^].

—SA
 
Share this answer
 
Comments
Mohibur Rashid 15-May-13 23:53pm    
his question was confusing, if it is all about printing data, then I would suggest the op to use FPDF or TCPDF or MPDF or whatever other pdf library is comfortable for him. Cause as a matter of fact to print formatted document with proper paper size and font size and proper alignment then pdf solution can be better.
Sergey Alexandrovich Kryukov 15-May-13 23:58pm    
Aren't you confusing something? Who mentioned anything related to PDF?
—SA
Mohibur Rashid 16-May-13 0:00am    
well, me, while i was talking about printing in php based application
Mohibur Rashid 16-May-13 0:00am    
as a matter of fact, I a have developed two ERP system where printing solution is PDF
Sergey Alexandrovich Kryukov 16-May-13 0:09am    
Understand, but I think this is irrelevant here. Don't you see: I suggested how to print just part of the page?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900