As database schema is not available, I’m assuming the structure like this.
Change it where you need.
registration table
Id | firstName | lastName | email | ....
Where, Id
is Primary Key
and auto-incremented
orders table
orderId | userID | orderName | ...
Where, orderId
is Primary Key
and auto-incremented
;
userID
is Id
of registration table.
So, when you are logged in through registration table. Create one session for Id.
$_Session['user_id'];
(Id
of registration table will be stored here.)
For viewing his/her orders
<?
$userID=$_SESSION['user_id'];
$orderQuery="SELECT * FROM orders WHERE userID=$userID";
.
.//Execute Your query
.
?>
4
solved how to fetch data from database in php if i have two table in database and i want to fetch from one table user id to others table data [closed]