By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,830 Members | 2,276 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,830 IT Pros & Developers. It's quick & easy.

printable version on web page

P: 64

Anyone can help me on how to create a printable version of MySQL data to be printed from PDF of Excel but moat preferably on the webpage?

[PHP]<? 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"></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">Details</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"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?view=detail&StockID=<?php echo $StockID; ?>">View</a></td> <td width="50"><a href="javascript:modifyStock(<?php echo $StockID; ?>);"><strong>Add </strong> </a></td> <td width="50"><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 '&nbsp;'; echo "</strong>"; ?></td> </tr> <?php } ?> <tr> <td colspan="7">&nbsp;</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.history.back();" class="button_image"></tr> </table> <p>&nbsp;</p> </form>[/PHP]
Sep 11 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 938

If you are outputting MySQL data on your webpage I'm gonna recommend you have a couple of CSS files - one to define the screen layout and one to define the print layout.

That way it looks great on screen and then looks great printed with no need to a 'printer friendly version' link

Just Goole 'print CSS'

You may run into issues using tables to control your layout. Perhaps consider switching to a CSS layout and using tables simply fro tabular data (sorry if I've misunderstood your code)

Sep 12 '08 #2

P: 161
Well about printed out to a pdf, you mite want to look into Headers.

BTW work on your formatting, bots and you are going to have issues looking at the code when they open them up and including other users looking at it, will discourage them helping you.


Use the first header function on the example

Example #1 Download dialog

If you want the user to be prompted to save the data you are sending, such as a generated PDF file, you can use the Content-Disposition header to supply a recommended filename and force the browser to display the save dialog.
// We'll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');

// The PDF source is in original.pdf
Sep 12 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.