Hello all.
I’m trying to retrieve information from database by using the following code. But unable to get the desired information.
Please kindly help me and advice me where I’m going wrong.
<?php
error_reporting(0);
require_once "includes/functions.php";
if(!loggedin())
{
header("Location: login.php");
}
else
{
require_once "includes/database.php";
require_once "thirdparty/fpdf/fpdf.php";
require_once "thirdparty/fpdi/fpdi.php";
if(isset($_POST))
{
$user = $_POST['username'];
$usql = "select id from users where username='$user'";
$ures = query($usql);
$urow = mysql_fetch_assoc($ures);
$uid = $urow['id'];
}
else
{
$uid = $_SESSION['USER_ID'];
$user = $_SESSION['USER_NAME'];
}
$sql = "select * from users u, userinfo ui, employer emp where u.id=ui.uid and ui.uid = emp.uid and u.id=$uid";
$res = query($sql);
$row = mysql_fetch_assoc($res);
//and all rest of my code for pdf generation.
Here first I’ve created a form with post method. post contains the username.
Now I want to retrieve the userid by using that username and then by using that userid, I want to retrieve all the information from all related tables.
How could I achieve this ?
My first part of the code is correct. I mean to say that I’m able to retrieve userid, but the next part of code is not fetching the infromation from all related tables.