i want to print the bill to printer from php mysql database?
is it possible?
help me please!!!!!

PHP is a server-side scripting language. If you need to control printing, that's going to be handled client side. For example, you can include a button on your page, or an icon of a printer that lauches the printer controls of the user's PC. What you need to do is display the page accordingly so it's layout is printer friendly. You do that by appying the appropriate styles. You can use the @media rule to set the layout printer friendly.

Hi as JorgeM said you need a js for it to be done...my suggestion is

  1. Full the data from your db and arrange it as you desire
  2. On page load use windows.print() or add a button or image that when click will call the print dialog box.

like

on page load

<html>
<head>

</head>
<body onload="window.print()">

<?php

DATA FROM DB


?>

</body>
</html>

or using an image or button

 <html>
<head>

</head>
<body>

<?php

DATA FROM DB


?>
<img src="printer.png" width="28" height="28" onclick="window.print()" />

<input type="button" value="Print this page" onclick="printpage()">


</body>
</html>

i have tried

<input type="button" value="Print this page" onclick="printpage()">

but it shows no output
and when i use

<img src="printer.png" width="28" height="28" onclick="window.print()" />

its open printer diup box, if is good for laser printer/color printer, but it cteate problem for DMP printer i want solution for DMP printer

Unless you have defined a printpage() function in JavaScript, that button will not do anything. Your <img> tag uses the right code window.print(), you could change the button to use the same thing:

<input type="button" value="Print this page" onclick="window.print()">

As for problems with a dot-matrix printer, those aren't going to be resolved by anything you can do in the browser. The print dialog opened by window.print() is the browser's print dialog the same as if the user chose to print the page themselves. What problems exactly are you encountering?

Hello sir i am developing a project where i want to print a page/part of the page from web browser without print window using javascript or php. could u please help me how i could do so? if possible then please send me code or process. thank u.

here i have a problem..

i want to print a page in php with image, but image is not print..
please help somebuddy..

@Lokesh_4 open a new thread, explain the issue and show the code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.