Jump to content

PHP printable version or PDF


gnawz

Recommended Posts

Hi.

 

I need help on how to generate a printable version of a report or records read from a MySQL database using PHP.

 

Below is my code

 


<?
require_once '../../functions.php';

$sql = "SELECT * FROM fragrancestock WHERE Quantity = '0'";
$rowsPerPage = 10;

$result     = dbQuery(getPagingQuery($sql, $rowsPerPage));
$pagingLink = getPagingLink($sql, $rowsPerPage);

?>
<form action="index.php?view=add" method="post"  name="frmList" id="frmList">
  <table width="700" border="0" align="center">
    <tr class="title_text"> 
      <td colspan="7"><? echo $errorMessage; ?></td>
    </tr>
    <tr class="title_text"> 
      <td width="200">Category</td>
      <td width="200">Brand</td>
      <td width="200">Available Stock</td>
      <td width="200">Date Added</td>
      <td width="50">View</td>
      <td width="50">Add</td>
      <td width="50">Delete</td>
    </tr>
    <?php
if (dbNumRows($result) > 0) {
$i = 0;

while($row = dbFetchAssoc($result)) {
	extract($row);

	if ($i%2) {
		$class = 'row1';
	} else {
		$class = 'row2';
	}

	$i += 1;
?>
    <tr class="<?php echo $class; ?>"> 
      <td width="200"><?php echo $Category; ?></td>
      <td width="200"><?php echo $Brand; ?></td>
      <td width="200" class="inner_border"><?php echo $Quantity; ?></td>
      <td width="200"><?php echo $DateAddedStock; ?></td>
      <td width="50" align="center" ><a href="<?php echo $_SERVER['PHP_SELF']; ?>?view=detail&StockID=<?php echo $StockID; ?>">Details</a></td>
      <td width="50" align="center" ><a href="javascript:modifyStock(<?php echo $StockID; ?>);"><strong>Add 
        </strong> </a></td>
      <td width="50" align="center" ><a href="javascript:deleteStock(<?php echo $StockID; ?>);">Delete</a></td>
    </tr>
    <?php
} // end while


?>
    <tr> 
      <td colspan="7" align="center"> 
        <?php 
   echo $pagingLink;
   ?>
      </td>
    </tr>
    <?php	
} else {
?>
    <tr> 
      <td colspan="7" align="center">No stock for <? echo '<strong>'; echo $ShowBrand; echo ' '; echo "</strong>"; ?></td>
    </tr>
    <?php
}
?>
    <tr> 
      <td colspan="7"> </td>
    </tr>
    <tr> 
      <td colspan="6" align="right"> <input name="btnAddStock" type="submit" value="New Entry" class="button_image"> 
      <td align="right"><input name="btnCancel" type="button" id="btnCancel" value="Return" onClick="window.location.href='index.php';" class="button_image"></tr>
  </table>
<p> </p>
</form>

Link to comment
https://forums.phpfreaks.com/topic/123750-php-printable-version-or-pdf/
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.