0

Unable to execute the sql query, only dispaying blank page.

<?php 
require('fpdf.php');
$today=date('d_m_Y');
$hostname = "localhost";
$database = "developer";
$username = "root";
$password = "";
$conn = mysql_connect($hostname, $username, $password) or die(mysql_error());
mysql_select_db($database, $conn);
class PDF_result extends FPDF {
    function __construct ($orientation = 'P', $unit = 'pt', $format = 'Letter', $margin = 40) {
        $this->FPDF($orientation, $unit, $format);
        $this->SetTopMargin($margin);
        $this->SetLeftMargin($margin);
        $this->SetRightMargin($margin);

        $this->SetAutoPageBreak(true, $margin);
    }

    function Header () {
      //   $this->Image('images/logo.png',100,15,200);
    //  $this->SetFont('Arial', 'B', 20);
    //  $this->SetFillColor(36, 96, 84);
    //  $this->SetTextColor(225);
        $this->Cell(0, 30, "PAYMENT DETAILS", 0, 1, 'C', true);
    }

 function Footer()
{
    //Position at 1.5 cm from bottom
    $this->SetY(-15);
    //Arial italic 8
    $this->SetFont('Arial','I',8);
    //Page number
    $this->Cell(0,10,'Generated at local server',0,0,'C');
}
function Generate_Table($i, $cardNo, $installmentAmount, $paymentDate) {

    $this->SetFont('Arial', 'B', 12);
    $this->SetTextColor(0);
//  $this->SetFillColor(94, 188, z);
$this->SetFillColor(94, 188, 225);
    $this->SetLineWidth(1);
    $this->Cell(30, 25, "Sno", 'LTR', 0, 'C', true);
    $this->Cell(120, 25, "Card No", 'LTR', 0, 'C', true);
    $this->Cell(100, 25, "Installment Amount", 'LTR', 0, 'C', true);
    $this->Cell(100, 25, "Paid Date", 'LTR', 0, 'C', true);

    $this->SetFont('Arial', '');
    $this->SetFillColor(238);
    $this->SetLineWidth(0.2);
    $fill = false;
}
    **function qry($qry)
{
    $this->$qry=mysql_query("SELECT cardNo, installmentAmount, paymentDate FROM payment order by cardNo",$this->$conn);
    if($this->$qry!=false)
{
    $i=1;
    while($this->$res=mysql_fetch_array($qry))
    {
        $myArr=array($i,$res['cardNo'],$res['installmentAmount'],$res['paymentDate']);
        $this->$i++;
    }**
}
}

    //for ($i = 0; $i < count($subjects); $i++) {
    //  $this->Cell(427, 20, $subjects[$i], 1, 0, 'L', $fill);
    //  $this->Cell(100, 20,  $marks[$i], 1, 1, 'R', $fill);
    //  $fill = !$fill;
    //}
    //$this->SetX(367);
    //$this->Cell(100, 20, "Total", 1);
//  $this->Cell(100, 20,  array_sum($marks), 1, 1, 'R');
}
$pdf = new PDF_result();
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 12);
$pdf->SetY(100);
$pdf->Cell(100, 13, "");
$pdf->SetFont('Arial', 'B');
$pdf->Cell(250, 13, $title);
$pdf->SetFont('Arial', 'B');
$pdf->Cell(50, 13, "Date:");
$pdf->SetFont('Arial','');
$pdf->Cell(100, 13, date('F j, Y'), 0, 1);
$pdf->SetFont('Arial', 'I');
$pdf->SetX(140);
//$pdf->Cell(200, 15, $_POST['e-mail'], 0, 2);
//$pdf->Cell(200, 15, $_POST['Address'] . ',' . $_POST['City'] , 0, 2);
//$pdf->Cell(200, 15, $_POST['Country'], 0, 2);
$pdf->Ln(100);
$pdf->Generate_Table($i, $cardNo, $installmentAmount, $paymentDate);
$pdf->Ln(50);
$message = "For More Information Contact us at : ";
$pdf->MultiCell(0, 15, $message);
$pdf->SetFont('Arial', 'U', 12);
$pdf->SetTextColor(1, 162, 232);
$pdf->Write(13, "support@domain.com", "support@domain.com");
$pdf->Output('result-.$today.pdf', 'F');
?>
2
Contributors
1
Reply
8
Views
2 Years
Discussion Span
Last Post by pritaeas
0
function qry($qry)
{
    $this->res = mysql_query("SELECT cardNo, installmentAmount, paymentDate FROM payment order by cardNo", $conn);
    if ($this->res != false)
    {
        $i = 1;
        while ($this->res = mysql_fetch_array($qry))
        {
            $myArr = array($i, $this->res['cardNo'], $this->res['installmentAmount'], $this->res['paymentDate']);
            $i++;
        }
    }
}

$this->$conn is not valid. It should be $conn because you set it outside of your class instance. You REALLY need to check your OOP code, because you are using instance properties wrong (syntax).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.