doudengjin8251 2016-07-14 10:20
浏览 94

从php生成pdf以表格形式从数据库中获取数据并通过电子邮件发送给用户

I want to fetch data from db in the form of table and generate pdf or excel of that data and want to send it to the user by email directly using php and sql.

Someone please help to solve me this problem. I dont want anyone to write code for me but give me some suggestions to solve it.

      <?php
session_start();
include ('db.php');
$db_link=mysqli_connect($hostname, $dbuser, $dbpassword,$dbname) or die("Unable to connect to the server!");
define('FPDF_FONTPATH','../font/');
require('fpdf.php');
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',10);
$pdf->Cell(25,7,"answerid");
$pdf->Cell(30,7,"email");
$pdf->Cell(30,7,"qst");
$pdf->Cell(30,7,"answer");
$pdf->Ln();
include ('db.php');
$db_link=mysqli_connect($hostname, $dbuser, $dbpassword,$dbname) or die("Unable to connect to the server!");

        $sql = "SELECT answerid,email,qst,answer FROM responses where email='".$_SESSION['usr_id']."'";
        $result = mysqli_query($db_link,$sql);

        while($rows=mysqli_fetch_array($result))
        {
            $id = $rows['answerid'];
            $email = $rows['email'];
            $question = $rows['qst'];
            $answer = $rows['answer'];
            $pdf->Cell(25,7,$id);
            $pdf->Cell(30,7,$email);
            $pdf->Cell(30,7,$question);
            $pdf->Cell(30,7,$answer);
        }
$pdf->Output();
?>
  • 写回答

1条回答 默认 最新

  • douwen5246 2016-07-14 10:22
    关注

    You can use tcpdf library for convert html into pdf file. You can generate pdf file and you can send it to user using php_mailer library. (Add generated pdf file as attachment.)

    评论

报告相同问题?

悬赏问题

  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算