I am presently working on the Report generation in PHP, which I found fpdf can help me out with the same. I would like to know how to display the current logged-in user details from the database on the pdf generated. Even if you could share with me any specific link pertaining to this.
My code to check if user is logged in
<?php if(isset($_SESSION['user_logged_in']))
{
$get_name=mysql_query("select * from mep_users where us_email='".$_SESSION['user_logged_in']."'")or die("error appeared"); while($get_nammer=mysql_fetch_array($get_name))
{ ?> <?php echo ' | '.$get_nammer['us_name']. " @ My Eye Prescription"; ?> <?php } } ?>
This is the query to retrieve the value that is stored in database table mep_user_content. I can see the record in the pdf file pertaining to id 17. But I would like to see the record entered by the user i.e. the new user logging in or the guest user with the respective id. Thanks.
$pdf->AddCol('rs',40,'Right Eye');
$prop=array('HeaderColor'=>array(255,150,100),
'color1'=>array(210,245,255),
'color2'=>array(255,255,210),
'padding'=>2);
$pdf->Table('select rs from mep_user_content where us_id="17"',$prop);
You are mixing database query with fpdf
. you need to deal separately whether you need to get database value or guest user value. Store appropriate values in variable and use that variable while generating PDF
file.
For example,
$required_value = "something"; // From database...
OR
$required_value = "something else"; // From guest user...
Now use $required_value
to place it in your pdf file.
EDIT:
$sess_id = $_SESSION['user_logged_in'];
$pdf->Table("select rs from mep_user_content where us_id='$sess_id'");