下载表格的pdf文件,并将数据保存在数据库服务器中

时间:2017-04-06 12:55:37

标签: php pdf

我需要知道如何在数据库中保存数据并同时下载它的pdf文件。我已经分别完成了这两个任务,但现在我需要一起执行这两项任务。我现在的代码只是保存数据库中的数据而不下载它的pdf文件 这是代码

$connection = mysql_connect('localhost', 'sujdhuj', 'msRQT0g(pqbX');
mysql_select_db('sujdhuj_dawoodDB',$connection);
if(!$connection){
    die("connection failed:" .mysqli_connect_error());
}
echo "connection hogya successful";
$Sno= $_POST['Sno'];
$Clientname= $_POST['Clientname'];
$Contactno = $_POST['Contactno'];
$Dos= $_POST['Dos'];
$Start= $_POST['Start'];
$End= $_POST['End'];
$Dow= $_POST['Dow'];
$Location= $_POST['Location'];
$Osi= $_POST['Osi'];
$Emhr= $_POST['Emhr'];
$Er= $_POST['Er'];
$Mir= $_POST['Mir'];
$Ea= $_POST['Ea'];
$Cr= $_POST['Cr'];
$Mir1= $_POST['Mir1'];
$Am= $_POST['Am'];
$Ca= $_POST['Ca'];
$Date= $_POST['date'];
$check= $_POST['option_3'];

//$Image= $_Post['image'];

$sql= "INSERT INTO surveyform(Sno, Clientname, Contactno, Dos, Start, End, Dow, Osi, Emhr,    Er,  Mir,    Ea,   Cr,    Mir1,    Am,   Ca,   Date, image) 
 VALUES('$Sno', '$Clientname', '$Contactno', '$Dos','$Start', '$End', '$Dow', '$Osi', '$Emhr', '$Er','$Mir', '$Ea', '$Cr', '$Mir1', '$Am', '$Ca', '$Date' ,'$Image')";

    if(!mysql_query($sql))
    {
        die('caution record not added' . mysql_error());
    }
        echo"1 record added";

require("fpdf/fpdf.php");
$pdf= new FPDF(); 
$pdf->AddPage();
$pdf->SetFont("Arial","I","15");
$pdf->Cell("0","10","Welcome Form {$Sno}","1","0","C");
$pdf->Ln(10);
$pdf->Cell("110","10","Client name","1","0","C");
$pdf->Cell("80","10","$Clientname","1","0","C");
$pdf->Ln(10);
$pdf->Cell("110","10","Contact no","1","0","C");
$pdf->Cell("80","10","$Contactno","1","0","C");
$pdf->Ln(10);
$pdf->Cell("110","10","Date of Service","1","0","C");
$pdf->Cell("80","10","$Dos","1","0","C");
$pdf->Ln(10);
$pdf->Cell("0","10","Dates are ","1","0","C");
$pdf->Ln(10);
$pdf->Cell("110","10","Start Time","1","0","C");
$pdf->Cell("80","10","$Start","1","0","C");
$pdf->Ln(10);
$pdf->Cell("110","10","End Time","1","0","C");
$pdf->Cell("80","10","$End","1","0","C");
$pdf->Ln(10);
$pdf->Cell("110","10","Duration Of Work","1","0","C");
$pdf->Cell("80","10","$Dow","1","0","C");
$pdf->Ln(10);
$pdf->Cell("110","10","Location","1","0","C");
$pdf->Cell("80","10","$Location","1","0","C");
$pdf->Ln(10);
$pdf->Cell("110","10","Other Special Instruction","1","0","C");
$pdf->Cell("80","10","$Osi","1","0","C");
$pdf->Ln(10);
$pdf->Cell("110","10","Estimated man hours Required","1","0","C");
$pdf->Cell("80","10","$Emhr","1","0","C");
$pdf->Ln(10);
$pdf->Cell("110","10","Equipment Required","1","0","C");
$pdf->Cell("80","10","$Er","1","0","C");
$pdf->Ln(10);
$pdf->Cell("110","10","Manager/ Surveyor in-Charge Remarks","1","0","C");
$pdf->Cell("80","10","$Mir","1","0","C");
$pdf->Ln(10);
$pdf->Cell("110","10","Estimate Amount","1","0","C");
$pdf->Cell("80","10","$Ea","1","0","C");

$pdf->Ln(10);
$pdf->Cell("110","10","Client Remarks:","1","0","C");
$pdf->Cell("80","10","$Cr","1","0","C");
$pdf->Ln(10);
$pdf->Cell("110","10","Manager/ Surveyor in-Charge Remarks:","1","0","C");
$pdf->Cell("80","10","$Mir1","1","0","C");
$pdf->Ln(10);
$pdf->Cell("110","10","Account Manager","1","0","C");
$pdf->Cell("80","10","$Am","1","0","C");
$pdf->Ln(10);
$pdf->Cell("110","10","Customer Name:","1","0","C");
$pdf->Cell("80","10","$Ca","1","0","C");
$pdf->Ln(10);
$Date=date('F j, Y');
$pdf->Cell("110","10","Date","1","0","C");
$pdf->Cell("80","10","$Date","1","0","C");
$pdf->Ln(10);
$pdf->Cell("110","10","Checkbox value","1","0","C");
$pdf->Cell("80","10","$check","1","0","C");

$pdf->Output("D", 'filename.pdf' );

0 个答案:

没有答案