如何在vb.net中打印网页

时间:2010-02-23 10:29:38

标签: mysql vb.net

我目前有这个代码用于在mysql数据库中打印一个表,但是有一个问题,当我打印表时也会显示打印按钮。你知道任何替代甚至是vb.net代码,它们将打印vb.net中当前在web浏览器上的内容(从用于查看网页或php文件的工具箱中拖出的那个)。

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("hospital", $con);

$result = mysql_query("SELECT * FROM t2 WHERE NURSE='{$_POST["nurse"]}'");

echo "<font='2'><b>ST. CATHERINE HOSPITAL</br> </font>";
 echo "<font='1'>CENTRAL EAST BANGAR LA UNION</b></font>";
echo "<table border='1'>
<tr>
<th>HospNum</th>
<th>RoomNum</th>
<th>LastName</th>
<th>FirstName</th>
<th>MidName</th>
<th>Address</th>
<th>TelNum</th>
<th>Nurse</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
   echo "<tr>";
  echo "<td>" . $row['HOSPNUM'] . "</td>";
  echo "<td>" . $row['ROOMNUM'] . "</td>";
    echo "<td>" . $row['LASTNAME'] . "</td>";
      echo "<td>" . $row['FIRSTNAME'] . "</td>";
        echo "<td>" . $row['MIDNAME'] . "</td>";
          echo "<td>" . $row['ADDRESS'] . "</td>";
           echo "<td>" . $row['TELNUM'] . "</td>";
            echo "<td>" . $row['NURSE'] . "</td>";

  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?>

<form>
<input type="button" value="Print" onClick="window.print();" /> 
</form>

1 个答案:

答案 0 :(得分:1)

您可以为打印介质使用专门的样式,以便在呈现页面进行打印时隐藏按钮:

<style type="text/css">

@media print {

    input[type=button] { display: none; }

}

</style>