hi
can any one share some possible way to print an invoice when some thing is registered in a form using PHP and redirects it to html page for printing

my form is ok and stores data.... redirects to the disered page as well now i have html lay out which needs to be filled in with the values stored or being posted .... OOP project how should i manage that the values that are being stored in the form should be visible on the page after redirection ..... I DONT KNOW AJAX at the moment

Member Avatar for diafol

I DONT KNOW AJAX at the moment

There's no substitute for learning :)

You could store the values from the form in session variables and just retrieve them from there. You could retrieve the values from the DB.

Member Avatar for iamthwee

I would also look into generating the form as a pdf for printing. The best I've come across so far that doesn't require any specific php libraries or cost anything is fpdf (check it out).

iamthwee my web application that im trying to make requires a faster output to as print so in tht case i think that pdf file would be a lower way ....

diafol .... in my case i would prefer a record shown from the DB as they print should match the exact records... can u send me sample code !!!

here is the code from my file which needs to be filled i have tried some thing but cannot carry it on further ..... i connected to DB fetched an Array and know how to displa y results in seperate feilds

<?php
require_once("classes/WebInterface.php");
require_once("classes/User.php");
require_once("includes/ptop.php");


if(isset($_SESSION['errors']))
{                   
    $errors = $_SESSION['errors']; 
}

if(isset($_SESSION['objUser']))
{                   
    $objUser = unserialize($_SESSION['objUser']); 
}

else
{
    $objUser = new User();  
}
?>

 </head>
 <body>
        <table border='1' cellpadding= '1'  width='1000px' height='400px' align='center'>

                <tr height='100px'>
                        <td><?php

                            $sqlSelect = "SELECT `StudentfName`, `StudentmName`, `StudentlName`, `ParentfName`, `ParentmName`, `ParentlName`, `enumber`, `Gender`, `dateofbirth`, `Testdate`, `Testtime`, `Class`, `tempID`, `Testfee`, `Username`, `Timereg` FROM `entrytest` ";
                                //echo $sqlSelect;
                                $tresult = @mysql_query($sqlSelect, $this->get_Conn());
                                //die("ss");
                                //$dataCount = mysql_num_rows($result);
                        //echo $dataCount;
                                if(mysql_num_rows($tresult) == 0)
                                {
                                    throw new Exception("Login Failed");
                                }

                                $userData = mysql_fetch_assoc($tresult);
                                extract($userData);

                                ?>
                            <table border='1' height='100%' width='100%'>
                                <tr>
                                        <td width='50px'></td>
                                        <td> <img  src='images/logo-gray-yellow.png' width='180' height='67' align="center"></td>
                                        <td width='500px'>
                                                <table cellpadding= '0' align='center' border='1'>
                                                <tr>
                                                        <td >
                                                        <h1> National Pre Cadre High School</h1>      
                                                        </td>

                                                </tr>
                                                <tr>
                                                        <td align='center'>
                                                            adress
                                                        </td>
                                                </tr>

                                                </table>

                                        </td>
                                        <td width='200px'>
                                                <table cellpadding= '0' align='center' border='1'>
                                                <tr>
                                                        <td >
                                                        <h1> Entry Test Examination Slip</h1>     
                                                        </td>

                                                </tr>


                                                </table>

                                        </td>

                                        <td width='200px' align='center'>
                                                <table cellpadding= '1'>
                                                <tr>
                                                        <td align='center'>
                                                            Registration time:  
                                                        </td>

                                                </tr>
                                                <tr>
                                                        <td>
                                                            <h4> </h3>    
                                                        </td>
                                                </tr>
                                                </table>
                                        <td></td>
                                </tr>
                            </table>
                        </td>
                </tr>
                <tr>
                        <td>

                            <table width='100%' cellpadding= '1' border='1'>
                                        <tr>
                                                <td align='center'>
                                                        Student Name:   
                                                </td>
                                                <td align='center'>

                                                </td> 
                                                <td align='center'>
                                                        Parents/Guardian Name:      
                                                </td>
                                                <td align='center'>
                                                        Date of birth:  
                                                </td>
                                                <td align='center'>
                                                        Class Registration: 
                                                </td>

                                        </tr>

                                </table>
                            <table width='100%' cellpadding= '1' border='1'>
                                        <tr>

                                        </tr>

                                </table>
                            <table width='100%' cellpadding= '1' border='1'>
                                        <tr>
                                                <td align='center'>
                                                        Registration time:  
                                                </td>
                                                <td align='center'>
                                                        Registration time:  
                                                </td>
                                                <td align='center'>
                                                        Registration time:  
                                                </td>
                                                <td align='center'>
                                                        Registration time:  
                                                </td>

                                        </tr>

                                </table> 
                        </td>
                </tr>
        </table>
 </body>

well some fields need to be changed according to data fields being Fetched ..... but i guess they we would call out one result the others would be called out the same way ..... and I need to congatinate the first middle and last name to show as one field

Member Avatar for diafol

Here's a clue:

<td align='center'>
    Student Name:  <?php echo $userData['StudentfName'] . ' ' . $userData['StudentmName'] . ' ' . $userData['StudentlName'];?>
</td>

the lay out goes total blank and when i remove the Sql Query it comes back !!

Member Avatar for diafol

I missed this:

extract($userData);

For that:

<td align='center'>
    Student Name:  <?php echo "$StudentfName $StudentmName $StudentlName";?>
</td>

As for your disappearing act - not sure I understand.

my HTML lay out does not appears when i add the aboe php code near body header the below function disappears....

Member Avatar for diafol

You're surpressing errors with this:

$tresult = @mysql_query($sqlSelect, $this->get_Conn());

So, odd - try:

$tresult = mysql_query($sqlSelect);
if (!$tresult) die('Invalid query: ' . mysql_error());

just to see if query is ok. Then we can proceed through the code.

//EDIT

Wait up, I just noticed (I'm slow) that your php loop is mixed up in the table.
It would be cleaner if you could run all your php routines above the dtd and then just use a simple loop/echo in the table if possible.

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.