PHP - 如何使用id显示当前用户详细信息? [关闭]

I want to display a user's info on an account details page (account.php). I've already made the page unavailable for users who are not logged in. So, now my problem is I don't know how to connect to my database and fetch the data and only display their account info on the page. Each of my user has an id. The info for each user I want to display is the username, gender, and email. My database name is "appDevDB" and the table is "users", with the above entities. How do I do this?

Follow my steps :

1) Put session_start(); on very top on each page wherever going to use session variable.

2) After login store the currently logged user id in session $_SESSION['id']=$current_user_id;

3) An account page fetch the account info using $_SESSION['id'] like

select * from users where id=$_SESSION['id']