On the php page there are several ajax requests (for different data from the database). Is it necessary for each request to create a separate php file - a handler specified in the url, or can you manage with one file?
2 answers
Depends on the volume of requests, conversions and personal order in the code. In your case, you can do something like this:
$q['users'] = "SELECT FROM 'users' ... "; $q['news'] = "SELECT FROM 'news' ... "; ... if ($_GET['query'] && $q[$_GET['query']]) { $result = mysql_query($q[$_GET['query']]); ... } If you use the correct architecture using controllers and routing, such as MVC, creating a file for each request is not required; you only need to create a file for a group of requests.
I recommend that you look in the direction of PHP frameworks (for example Lavarel) or microframes in which you will not have problems in developing applications with the correct architecture. Creating separate files on the query approach, which entails a bunch of problems in supporting the project. Spend time studying, but further development will be easier and more efficient.