Recommend this page to a friend! |
Top level forums | > | PHP Specialists | > | General | > | Print a generated document |
|
Eve - 2011-01-03 04:06:16
I'm trying to allow the viewer to print/preview only the article that I generate for the web site. For the life of me, I can't get it to work. What am I doing wrong?
*********************************************************************** //This is my php file <tr> <td width="575" valign="top" rowspan="8"> <!--Begin article listing for category--> <div id="mainbody"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <?php $articleText = new GetRecord(); //instantiate the object $articleText -> get_ArticleText(); //call the function to get the actual article ?> <tr><td> <?php print("</td><p align='left' style='padding: 0 30px' class='MsoNormal' style='MARGIN: 0in 0in 0pt'><input type='button' onClick='fullwin($prtArticleText)' value='Print Article'></p></tr>\n"); ?> </td></tr> </table> <!--End of Article Listing--> </div> </td> </tr> ********************************************************************* //This is my javascript function fullwin(sPrtText) { var aWindow = window.open("","Article","fullscreen,scrollbars"); aWindow.document.write(sPrtText); } ********************************************************************** //This is from my class. The $prtArticleText is public. function get_ArticleText() { $artnum=($_GET["artnum"]); mysql_connect("localhost", "root", "") or die("Could not connect: " . mysql_error()); mysql_select_db("test"); $result = mysql_query("SELECT article_title, article_subtitle, article_author, article_imagepath, article_videopath, article_text FROM article WHERE (article_id = '$artnum')") or die("Couldn't get data from ARTICLE table: ".mysql_error()); print("<tr><td>\n"); $prtArticleText = "<tr><td>\n"; while ( $row = mysql_fetch_object($result) ) { $myarttitle = $row->article_title; $myartsubtitle = $row->article_subtitle; $myartauthor = $row->article_author; $myartimage = $row->article_imagepath; $myartvideo = $row->article_videopath; $myarttext = $row->article_text; print("<tr><td><center><h1>$myarttitle</h1></center></td></tr>\n"); $prtArticleText = $prtArticleText + "<tr><td><center><h1>$myarttitle</h1></center></td></tr>\n"; if (strlen($myartsubtitle)> 0) { print("<tr><td><center><h2>$myartsubtitle</h></center><br></td></tr>\n"); $prtArticleText = $prtArticleText + "<tr><td><center><h2>$myartsubtitle</h></center><br></td></tr>\n"; } if (strlen($myartauthor)> 0) { print("<tr><td><center><i>by $myartauthor</i></center></td></tr>\n"); $prtArticleText = $prtArticleText + "<tr><td><center><i>by $myartauthor</i></center></td></tr>\n"; } print("<tr><td height='2' valign='top' bgcolor='#990000' align='left' width='100%' nowrap='nowrap'></td></tr>\n"); if (strlen($myartimage)> 0) { print("<tr><td> <br><img src='$myartimage' alt='article image' border='0' vspace='5' hspace='10' align='left'><p>$myarttext</p></td></tr>\n"); $prtArticleText = $prtArticleText + "<tr><td> <br><img src='$myartimage' alt='article image' border='0' vspace='5' hspace='10' align='left'><p>$myarttext</p></td></tr>\n"; } else { print("<tr><td>$myarttext</td></tr>\n"); $prtArticleText = $prtArticleText + "<tr><td>$myarttext</td></tr>\n"; } } $artlabel = $myarttitle; /*$arturl = '<a href="http://127.0.0.1/articletext.php?artnum=' .$artnum. '">' .$artlabel. '</a>'; */ $arturl = '<a href="/articletext.php?artnum=' .$artnum. '">' .$artlabel. '</a>'; $trail = new Breadcrumb(); $trail->addBreadcrumb($artlabel,$arturl,2); // Now output the navigation /*if (basename($_SERVER['SCRIPT_NAME']) !== index.php){ $trail->output();} */ $trail->output(); return $result; mysql_close("test"); } There are 3 replies in this thread, which are not being displayed. |
info at phpclasses dot org
.