I am having this SQL query in page2.php:
SELECT *
FROM events
WHERE event id=?
In page1.php, I am have the calendar. How can I pass the id from page1 to page2 and display the output in page1?
You need to use the events (as a function) or events (as a json feed) to fetch the events, and you can pass the id as a parameter in the url.
in the first case you need to add in the data object the id: yourID and in the second case like events: "/myfeed.php?id="+yourID
On the PHP side you will need to use the $_GET to retrieve that id in order to use it in your query
page1 and how ? javascript or php access ?hmm ... if you call the two pages from the browser, use sessions or cookies,
if you want to call page2 from page1 use INCLUDE("page2.php"). you can access variables from page1 in page2 then.