Results 1 to 9 of 9

Thread: code check please

  1. #1
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question code check please

    Hello .
    I am trying to print command this. I understand you use javascript window.print but how do I do this? I know you can not mix it like this. But I want to print the gets and image and words ID# and Member Since in control sized window and Print Command. Any ideas?
    Thanks
    Code:
    <table width="280"><tr><td valign="center">
    <img src="http://www.domain.com/media/images/badgelogo.gif"><br>
    <?= $_GET["PrimPhoto"]; ?><br>
    <?= $_GET["Name"]; ?><br>
    <?= $_GET["Title"]; ?><br>
    ID# <?= $_GET["ID"]; ?><br>
    Member Since
    <?= $_GET["DateReg"]; ?>
    </div><br>
    <form id="printMe" name="printMe"> <input type="button"
    name="printMe" onClick="printSpecial()" value="Print Badge"> </form>
    </td></tr></table></center>
    Last edited by Snookerman; 06-10-2009 at 07:52 AM.

  2. #2
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    I'm not sure I fully understand your requirement but I've modified your code.

    There is now a button that says 'Prepare Badge', this opens a window with the badge preview inside and a button that allows the javascript window.print function to be used to print the contents of the popup.

    with PHP I personally prefer to create PDF documents, I find ezPDF quite easy to use.

    PHP Code:
    <SCRIPT LANGUAGE="JavaScript"> 
    function openindex()
          { 
    OpenWindow=window.open("", "newwin", "height=250, width=250,toolbar=no,scrollbars="+scroll+",menubar=no");
    OpenWindow.document.write("<TITLE>Title Goes Here</TITLE>");
    OpenWindow.document.write("<BODY BGCOLOR=pink>");
    OpenWindow.document.write("<h1>Test!</h1>");
    OpenWindow.document.write("Your Photograph is : <?php echo $var1?><br>");
    OpenWindow.document.write("Your Name is : <?php echo $var2?><br>");
    OpenWindow.document.write("Your Title is : <?php echo $var3?><br>");
    OpenWindow.document.write("Your ID is : <?php echo $var4?><br>");
    OpenWindow.document.write("<br>");
    OpenWindow.document.write("<br>");
    OpenWindow.document.write('<form id="printMe" name="printMe"> <input type="button" name="print" onClick="window.print()" value="Print Badge"> </form><br>');

    OpenWindow.document.write("</BODY>");
    OpenWindow.document.write("</HTML>");

    OpenWindow.document.close()
    self.name="main"
         }
    </SCRIPT>

    <table width="280"><tr><td valign="center">
    <img src="http://www.domain.com/media/images/badgelogo.gif"><br>
    <? 
    $var1
    ="your photo";
    $var2="your name";
    $var3="Title";
    $var4="ID";
    ?>
    <?= $_GET
    ["PrimPhoto"]; ?><br>
    <?= $_GET["Name"]; ?><br>
    <?= $_GET["Title"]; ?><br>
    ID# <?= $_GET["ID"]; ?><br>
    Member Since
    <?= $_GET["DateReg"]; ?>
    </div><br>
    <form id="printMe" name="printMe"> <input type="button"
    name="printMe" onClick="openindex()" value="Prepare Badge"> </form>
    </td></tr></table></center>

  3. #3
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for answering. I like the idea. But how do you suggest they upload their picture and have it show along with all info?
    Also would I save this file as .html or .php?

  4. #4
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok I tried your script and did not get the variables. Contact you PM

  5. #5
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    This file is PHP.

    I would suggest that there is a previous form with a line for <input type="file">, to get the image as well as the rest of their information.

    If you want you can have the image file transferred to a directory on your domain and the path to it and all their other details stored in a database.

    The next step in the process, a second page, would be to present them with details of what they have entered and the option to print.

    Another option would be to do all of this on a single PHP page, using if (isset($_POST['submit']));, and only presenting the print option if it passes the test.

    This way you don't have to store anything on your domain.

    As they say 'the choice is yours', it really depends on how, and why, you are taking these details.

  6. #6
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I tried some things but did not get it to work. Thanks

  7. #7
    Join Date
    May 2009
    Posts
    62
    Thanks
    19
    Thanked 3 Times in 3 Posts

    Default

    waaaaaaa.... Is it possible to combine php and javascript?

  8. #8
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    It certainly is, there are a number of ways to do this.

    This is what I use to have an 'alert' feature in my PHP:

    PHP Code:
    function alert($alert) {
    $out .='<script type="text/javascript">
       alert("'
    .$alert.'");
       </script>
       '
    ;
       
    print 
    $out;


    or you can echo the javascript lines along with the HTML, you can also break out of PHP to use HTML and put normal javascript in the <head> section

  9. #9
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Think of your php code as a set of instructions that your server uses to write your web pages for you.

    Uh... yeah.
    That's actually a fairly literal analogy.

    So, anything you can write, php can write too.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •