...

View Full Version : update database on print?



turpentyne
03-06-2012, 03:55 PM
I've got a simple script that generates a button that sends to the printer when clicked. But a totally new thing to me is finding a way to update a "printed_unprinted" field in the database for that item. Anyone have experience with this?

Right now, I just have:
<style type="text/css" media="print">
@page { size:8.5in 11in; margin: 1cm }
.printbutton {
visibility: hidden;
display: none;
}
</style>

<script>
document.write("<input type='button' " +
"onClick='window.print()' " +
"class='printbutton' " +
"value='Print This Page'/>");
</script>


I assume I could reference a php file? Just something quick like:


<?php
include("include/conn.php");

$id = mysql_escape_string($_POST['printed']);

$query_update = "UPDATE tbl_registration SET reg_hardcopied = '1' WHERE reg_id = '$id'";
$dberror = "";
$ret = mysql_query($query_update);
if(!$ret){}
else{
//back to referrer

}



?>

felgall
03-06-2012, 08:18 PM
There are several other ways to print without pressing a button. There's no way to tell if someone printed something or not.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum