基于编码"如何仅在编码中打印此部分"。
echo'<br/><br/>Token number : '.$row3['Token_ID'].'<br/>Patient Name : '.$row3['Name'].'<br/>Doctor Name: '.$row3['Doctor_Name'].'<br/>Room Number: '.$row3['Room_Number'].'<br/>';
这里是完整的编码:
<html>
<head>
<title>Clinic Management System </title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<?php
include ('./includess/header2.html');
?>
<body>
<center><h2><b>Token Registration</b></h2></center>
<form action ='Token_Registration.php' method = "POST">
<div id="frm"><legend>Token information :</legend>
<input type="text" name="search" placeholder="Search for IC...."/>
<input type="submit" name="submit1" value="Search"/>
<?php
$page_title = 'Register';
if (isset($_POST['submit1']))
{
$nic = $_POST['search'];
require_once ('mysql_connect.php');
$query1 = "SELECT * FROM patients WHERE IC_Number = '$nic'";
$result1 = @mysql_query($query1);
$num1 = @mysql_num_rows($result1);
if ($num1 >0)
{
while($row1 = @mysql_fetch_array($result1, MYSQL_ASSOC))
{
$_SESSION['paid'] = $row1['ID'];
echo
'<br/><br/>Name : '.$row1['Name'].'<br/> Patient ID :'.$row1['ID'].'<br/>';
}
}
else
{
echo '<br/><font color="red"> Wrong IC number or Person does not exist </font>';
}
}
?>
<p><b>Doctor Name :</b> <input type ="text" name = "Doctor_Name" /></p>
<p><b>Room Number :</b> <input type ="text" name = "Room_Number" /></p>
<div align ="left"><input type = "submit" name = "submit" value = "Register" /><p><input type="button" onclick="window.print()" value="Print Here"/></div>
<?php
$page_title = 'Register';
if (isset($_POST['submit']))
{
$paid = $_SESSION['paid'];
/*$pname = $_SESSION['pname'];*/
require_once ('mysql_connect.php');
$rnum = $_POST['Room_Number'];
$dname = $_POST['Doctor_Name'];
/*$query2 = "INSERT INTO token (Patient_ID, Doctor_Name, Patient_Name) VALUES ('$paid', '$dname', '$pname' ) "; */
$query2 = "INSERT INTO token (Patient_ID, Room_Number, Doctor_Name) VALUES ('$paid','$rnum', '$dname') ";
$result2 = @mysql_query($query2);
if ($result2)
{
/*$query3 = "SELECT * FROM patients ,token WHERE ((patients.ID = token.Patient_ID AND token.Patient_ID = '$paid') AND (patients.Name = token.Patient_Name AND token.Patient_Name = '$pname'))"; */
$query3 = "SELECT * FROM patients ,token WHERE patients.ID = token.Patient_ID AND token.Patient_ID = '$paid'";
$result3 = @mysql_query($query3);
$num3 = @mysql_num_rows($result3);
if ($num3 >0)
{
while($row3 = @mysql_fetch_array($result3, MYSQL_ASSOC))
{
echo'<br/><br/>Token number : '.$row3['Token_ID'].'<br/>Patient Name : '.$row3['Name'].'<br/>Doctor Name: '.$row3['Doctor_Name'].'<br/>Room Number: '.$row3['Room_Number'].'<br/>';
}
}
else {
echo "Error";
}
}
}
?>
</form>
</div>
<?php
include ('./includes/footer.html');
?>
</body>
</html>
答案 0 :(得分:0)
将您要打印的内容打包在<div id="printPortion">
您可以使用带有单击功能的按钮来触发打印,然后使用以下代码仅打印div的内容。
您可以使用javascript打印所需的内容
var restorePage = document.body.innerHTML;
var printPortion = document.getElementById('printPortion').innerHTML;
document.body.innerHTML = printPortion;
window.print();
document.body.innerHTML = restorePage;