I'm basically using this to display results from my MySQL database in an interactive real-time AJAX-like fashion. How can I add more columns? Also if I add something to the database will it update on the AJAX page?
Omar Abdallah - 2009-11-06 11:27:54 - In reply to message 1 from Josh LaMar
Adding new columns is simple,
1. You will have to do this in your query ( make sure you use the same query for the page itself and the subpage that loads by ajax)
2. You will edit the display table to add the additional column
3. If you want to make it searchable you will have to add to 'fields' array
Example case:
Let's say you have another column called age
I'm gonna change the follwing
query: $query = "SELECT id, name, age FROM customers"; or just use astrisk
and you also have to do the same changes on the subpage.php
About a realtime database update. I did not implement it but sure you can... actually its much easier using Jquery's ajax. but I didn't use it in the examples just to make it easy to understand for developers who are not familiar with jquery.
If you have any other questions you are most welcome.
Josh LaMar - 2009-11-06 17:40:53 - In reply to message 2 from Omar Abdallah
Let's say I want to add a sorting feature where I can just click on table heading (let's say Name) and it sorts it in alphabetical order. How about numerical (such as ID) and chronological order (such as date)?
Josh LaMar - 2009-11-07 18:20:55 - In reply to message 2 from Omar Abdallah
I was looking at the jQuery Ajax functions (http://docs.jquery.com/Ajax) and wasn't sure how to go about displaying an interactive live-updating MySQL database using jQuery's Ajax. Did you have something specific in mind?
To be more specific I have a design for a leader board for a bicycle race. I'm using RFID to track the lap times and those times are recorded to a MySQL database. I want to change rider position automatically each time the database gets a new read. The more animated and user interactive I can get the leader board to be the better, which is why I think jQuery was a good suggestion. Any thoughts?
Omar Abdallah - 2009-11-07 23:27:47 - In reply to message 4 from Josh LaMar
The documentation of jquery.com is a bit poor. see this tutorial: ibm.com/developerworks/library/x-aj ...
or google : jquery ajax tutorial
you'll get what you need.
for the position thing I thing you'll have to call the server on time intervals.. let me think and get back to you. I've searched alot for implementing a sleep function in js but nothing's working till now..
Omar Abdallah - 2009-11-08 00:21:45 - In reply to message 4 from Josh LaMar
I've found the solution
The concept is about recursion
You'll have the php script on the server to send a flag to continue requesting the position or the race is finished.
function getPosition(){
// send the ajax request
if (raceEnded == false){
// do the html work to move the players
getPosition();
}else{
// halt the execution of the function
return false;
}
}