H
H
hrvasiliy2014-10-13 13:30:28
PHP
hrvasiliy, 2014-10-13 13:30:28

How to pass a variable to another file?

There are 2 files. 1: main page 2: the page that executes the script. The main page is only responsible for formatting the data output without reloading the page. On the second page, all manipulations take place: the script takes data from the database and displays them. I want to make an output filter from the database, for example, display numbers from 1 to 3 + category checkboxes (On the main page). As far as I understand, I need to pass the variable from and to to my second file, and then write the condition in sql. But I don’t understand how to transfer variables to this second file, I don’t want to make a form with a submit button, since there shouldn’t be page reloads at all ... I read about sessions, I don’t quite understand how to accept a variable from the user and write it to the session. It would not be bad if you could tell me which way to look :) Thank you

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Entelis, 2014-10-13
@hrvasiliy

A question with a bunch of contrived restrictions.
1. Read about MVC. And the code will become clearer and more readable, and there will be no page references.
2. If you want without reloads - you need to write a js code that, when the form changes, will send an ajax request and render it to the page accordingly.
api.jquery.com/jquery.ajax at the very end examples

F
FanatPHP, 2014-10-13
@FanatPHP

I don't want to do a form with a submit button,

Wishlist and whims we leave at home. After that, we arm ourselves with knowledge and technology.
I prompt:
To look towards the standard form, with reset. To get at least a glimpse of what you are doing and what technology you are working with .
After you master the standard version with preload, and it finally works, you can try to master the AJAX technology in order to do it without reloading.

V
vidoff, 2014-10-13
@vidoff

it is possible through $_GLOBAL['X'] or simply global $x; maybe something else too...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question