I am new in PHP
. I use session first time. I have two tables in db. First table with name pacra_teams
with column id and title. Second table is og_users
with multiple column but i use team_title
as foreign key
as store id against team title.
Now i want to create a session
and want to display team name from table pacra_teams
and user name from table
og_users
.
I try following code but i failed.
<?php
// starts session
session_start();
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "pacra1";
$conn = new mysqli($servername, $username, $password, $dbname);
$sql="SELECT *
FROM og_users
LEFT JOIN pacra_teams
ON og_users.id = pacra_teams.id
LIMIT 1
";
// setting variable values during session
$_SESSION['og_users.username']=$username;
$_SESSION['pacra_teams.title']=$title;
?>
call these variables
<?php
session_start();
?>
<?php
print_r($_SESSION);
?>
Please help me how i can do this?
One Thing More. if i run seesion.php page it display undefine variable "title" and if i run print code. It display username "root" but i dont have any user name root in my db