Displaying dynamic data from a table if logged in php/mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
meisenheimere
Forum Newbie
Posts: 1
Joined: Sun Mar 06, 2011 7:30 am

Displaying dynamic data from a table if logged in php/mysql

Post by meisenheimere »

Essentially, i have a database setup with several tables that store various info. I have a table named "members" for member information (username/password/contact details etc.), and a table named "events" for dynamic global variables. What i mean by that is the table has variables that are updated and displayed collectively by the users that are currently logged in. The variables (all integers) are constantly changing (basically on a second to second basis) based on user input and need to be displayed and updated in the "events" table if lets say, the user presses a button after having logged in. So to sum it up, i'm trying to figure out a way to have relatively instantaneous dynamic data displayed on the press of a button. If this is more of a mysql question, i apologize, but i just wasnt sure exactly where to ask. Any comments or advice will be greatly appreciated.

The goal i'm trying to achieve is something like this:

if(user=logged_in){
if(int<500){
onClick(connect to database and display int from table "events");
int++;
update int in table "events";
}
}

I know onClick doesn't work in php, but i have a system of iframes that just load php scripts to simulate onClick, so disregard that. I was thinking if there was a way to just have the int displayed inherently, only hidden, and just have it show and update onClick, that would probably also work. The quicker, the better. Again, any insight into this situation will be greatly appreciated :)

EDIT: I'm using session variables to track the login and other statistics. So if there is maybe a way to constantly update session variable from data in a database table, that would be okay too.
litebearer
Forum Contributor
Posts: 194
Joined: Sat Mar 27, 2004 5:54 am

Re: Displaying dynamic data from a table if logged in php/my

Post by litebearer »

perhaps using ajax to 'refresh' the displayed data every x seconds - similar to a stock-ticker-tape
Post Reply