I'm storing the user type (seller or buyer) in one of my session variables as $_SESSION['user_type']
.
Some of my select / insert / update queries require the columns by the name of seller_id
or buyer_id
.
I want to know if there's a way by which I can add the _id
suffix to $_SESSION['user_type']
in my queries.
For example: If I want to select all the columns from my order
table where buyer_id
is equal to 7
, my query should look something like this:
SELECT *
FROM `order`
WHERE ( $_SESSION['user_type'] + "_id" ) = '7'
Note: I know I can use a variable and generate the corresponding column name, but was wondering whether this is possible without any extra variable.