print individual tables ??
- by LiveEn
I am getting values from a database and displaying in a table. Im trying to print the results as individual .
Im using the below javascript
<script type="text/javascript">
function print_parent(element)
{
element.parentNode.className = 'print';
window.print();
element.parentNode.className = '';
return false;
}
</script>
The problem that i have is when i try to print all the results it works great.can some one please tell me how can i print each individual table in each result please?
below is my php code
$sql="select * from cisdb where pids LIKE '%$pids%'";
$result=mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result)==0) {
echo '<b><center>There was no records !</center></b>'."<br>";
}
while ($row=mysql_fetch_array($result)) {
$cat=str_replace('+', ' ', $row['category']);
print "<center>";
print "<table width='472' border='1' align='center' class='noprint'>";
print "<tr>";
print "<td width='150'><div align='center'><a href='#' onclick='return print_parent(this)'>Print</a>
</div></td>";
print "<td width='150'><div align='center'><a href='process.php?mode=ed&id={$row['id']}'>Edit</div></td>";
print "<td width='150'><div align='center'><a href='process.php?mode=del&id={$row['id']}' onclick='return confirm('Are you sure you want to delete?')'>Delete</a></div></td>";
print "</tr>";
print "</table><br>";
print "<div id='divToPrint'>";
print"<table width=700 style=height:900 border=1 cellpadding=1 cellspacing=1 bordercolor=#D6D6D6 class=sss title={$row['title']}>
<tr>
<td height=25 colspan=2 align=left valign=top><strong>Customer:{$row['name']}</strong></td>
<td width=183 align=left valign=top><strong>Sales ID:{$row['said']} </strong></td>
<td width=100 align=left valign=top><strong>Phone Cord. ID:{$row['pcid']}</strong></td>
<td align=left valign=top><strong>Type:{$row['classtype']}</strong></td>
</tr>
<tr>
<td height=25 colspan=2 valign=top><strong>Contact Name: </strong></td>
<td colspan=2 valign=top><strong>Email:</strong></td>
<td width=154 valign=top><strong>Phone:</strong></td>
</tr
<tr>
<td height=15 colspan=5 valign=top><strong>Remarks:</strong></td>
</tr>
<tr>
<td height=15 colspan=2 valign=top><strong>Date Added: </strong></td>
<td valign=top><strong>Date Edited : </strong></td>
<td colspan=2 valign=top><strong>Printed : </strong></td>
</tr>
</table></div><br>";
print "</center>";
}