Background: I'm doing a little spare time job for a friend, making use of his RFID-reader and card.
Problem: The C part was cake, took no longer than an hour or two to set it up against a MySQL database. Problem is that he wants a web-based solution, and I'm dogsh*t with all web-based programming languages.
I need a script that updates another script, and I'm not sure how to go about it. I've tried Googling and searching this site, but I can't seem to quite understand the solutions posted.
This is the part which I want updated once a second or so. Overload due to many updates shouldn't become a problem. This is the sql-query:
$sql = "SELECT * FROM card_info ORDER BY datetime DESC LIMIT 1";
I've already set up code to run it when someone clicks a button, but I would like to run that query once a second or so so that it updates to the very latest card that was placed on the reader, in order to print it on the screen. Either that or have it run every time that table in the MySQL-database updates.
I'm simply not sure how to go about this, there are finished scripts which I don't quite understand how to point towards this script in particular. I doubt cronjobs are any use in this instance. Any ideas what-so-ever are much appreciated!
/Juni
Update: The code strip which I want to poke:
if(isset($_GET['fetchid'])) {
$sql = "SELECT * FROM card_info ORDER BY datetime DESC LIMIT 1";
if($mysqli = connect_db()) {
$result=$mysqli->query($sql);
}
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_array($result)) {
echo "Current card id is: " . $row['id'] ."." ;
}
}
}
Which fetches the latest db-entry, and would be good to have updated in realtime.