I am very new to sql and php world and I need to extract some data from the database according to the user id who is viewing the page. The sql code is as follow:
SELECT woo_order_id AS Orders, wp_byt_cruise_booking.ID AS Booking, woo_status AS Status, first_name AS Guest_1st_Name, last_name AS Guest_Name, email, post_title AS Retreat_Complete_Title, DATE_FORMAT(wp_byt_cruise_booking.created, "%D %b %Y") _Booking_Date_, DATE_FORMAT(cruise_date, "%D %b %Y") AS Retreat_Arrival_Date, total_cruise_price AS Retreat_Price, cart_price AS Deposit_Paid, FORMAT(earnings, 2) AS Earnings, DATE_FORMAT(start_date, "%D %b %Y") AS Payout_Request, DATE_FORMAT(end_date, "%D %b %Y") AS Payout_Date
FROM wp_byt_cruise_booking
INNER JOIN wp_posts ON cruise_id=wp_posts.ID
LEFT JOIN wp_byt_car_rental_availabilities ON woo_order_id=season_name
WHERE woo_status ='processing' OR woo_status ='completed'
AND post_author=1
ORDER BY _Booking_Date_;
For the last but one line, I want to add a variable which will automatically detect the user viewing the page. Something like: AND post_author = current_user
How can this be achieved by integrating some php code into this sql query?
Thanks in advance for the help