I would like to know how can I format a print out page which data were retrieved from mysql DB and activate the print function on windows os?
How to create a preview print out page and then click a button to print?
This is not a PHP thing. To create the print preview use CSS. That way, you won't even need to change the actual page at all, as the print stylesheet will be selected automatically if you set the media value to print.
Printing is a client-side action, so can only be triggered by client-side script, such as JavaScript:
window.print()