Real time Online Booking System

I am a beginner in programming, and I have recently came across this topic and having a lot of questions in my mind about this topic. Assume that I am creating this Booking application in PHP as Backend with SQL as the database and HTML + JS as the front-end, and for understanding purposes this is an empty booking system.

Questions:

  1. I have 20 seats to be booked and launching the server at a particular time and more than 100 users are trying to book these tickets after booking, a dummy payment process for little realistic. Assuming two users selecting the same seat or ticket at the same time what happens then? how the program will choose between them?

  2. Assuming One user wants to spam others so he just selects a seat and wait for long in the payment process, what happens to that seat?

  3. and so many questions like this? wondering how the real time applications like airline ticket system or amazon purchasing with limited stocks works?

Thanks in advance.