简体   繁体   中英

Update view when new record is inserted in a specific table

I'm doing an auctions website (not for any institution, just as part of my learning of php and cakephp). At Home page I have all the items displayed. What I need to do now is to refresh price / last licitation and time remaining in each item when any user makes a licitation.

So do you know how can I, in a view, keep watching licitations table for new records and then update those values in the view?

Attention: The new record in the database can be inserted by any other user.

Thanks.

You will have to use JavaScript to ask the server (your PHP script) if there are any changes, and then do the updating. You could use Comet for this. In short: Comet is a "technology" that allows you to be connected to the server constantly so that the server can send data to the client when said data is available (without the need to refresh a page).

You can either continuously refresh the page, or you can use AJAX to poll the server for changes and then update the page data. There is no good way to have the server notify the page directly - the page will have to ask about changes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM