#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    39
    Rep Power
    12

    Can I include javascript print in a php function?


    i have the following function and I can't get the javascript print window to work. it keeps returning a javascript error.

    function Print_Info()
    {
    $printquery = "SELECT prints FROM coupons WHERE coup_id = '$coup'";
    $printresult = mysql_query($printquery);
    $prints = mysql_result($printresult,0, 0);
    $prints = $prints + 1;

    $addprintquery = "UPDATE coupons SET prints = '$prints' WHERE coup_id = '$coup'";
    $addprintresult = mysql_query($addprintquery);

    echo "<SCRIPT language=javascript>window.print();</SCRIPT>";
    }



    anyone have any ideas? thx
  2. #2
  3. No Profile Picture
    I'm Coming Up
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Kansas
    Posts
    96
    Rep Power
    12
    PHP Code:
    <?
    function Print_Info()
    {
    $printquery "SELECT prints FROM coupons WHERE coup_id = '$coup'";
    $printresult mysql_query($printquery);
    $prints mysql_result($printresult,00);
    $prints $prints 1;

    $addprintquery "UPDATE coupons SET prints = '$prints' WHERE coup_id = '$coup'";
    $addprintresult mysql_query($addprintquery);
    ?>
    <SCRIPT language=javascript>window.print();</SCRIPT>
    <?
    }
    ?>
    That should work.
    Word to your mother.

IMN logo majestic logo threadwatch logo seochat tools logo