-1

I was wondering how can I add two different pages together in php. For example, I would like to have the time variable on about.php and contact.php page and if I change the time from one page, it will affect the other page at the same time. Is it possible to do this from the mysql database?

Thanks

slidejones55
  • 105
  • 1
  • 1
  • 5
  • if each page is selecting a variable from the db on each load, anything that changes that variable will be reflected on those pages next time they are loaded –  Mar 14 '19 at 01:02

3 Answers3

0

You may use a session for making your pages stateful if that is what you are asking. In my opinion using database call for this purpose would be an overkill. Try setting a session variable for the domain and you may call that variable from any page of that domain.

Please visit these links for further reference for session variables: PHP Sessions across subpages of same domain

If using javascript/jquery, you may also have a look at this: One Cookie - Multiple Pages

sushil
  • 9
  • 1
-1

i think you can do that use require('filename') in PHP, that function/built in make yout get variabel, class etc from another file like you want to do . that the reference : http://php.net/manual/en/function.require.php

Hope can help

-1

Here is my response.

The qusetion is, Do you want the time update to be real-time event or not.

Real-Time Event:

If you want the update to be real-time(Ie The Page will not refresh or reloads upon the event updates) then you better do it with nodejs and websocket. The most common websocket is Socket.Io.

Not-Realtime Event If its not gonna be real-time. You can then use php. You can write an update code in any of the page. You will then also write a code to query the time from the database. Embed the query codes on both pages so that each time the page reloads or refreshes, the time will be fetched from the database and it will work fine. Your best bet will be to combine php with ajax. Thanks You

Nancy Moore
  • 2,322
  • 2
  • 21
  • 38