I am storing a number in a MySql Database Table, specifically a row called "open" whose field is an integer value that nearly continuously changes. I want to be able to continuously pull this value and display it on the frontend HTML page and put it in a table, called something like "live values". I want the numbers on the frontend to change without need for page refresh and I am trying to figure out how/if I can do this.
Is it possible to pull the value of the data to the frontend, using PHP, asynchronously?
You need to program a little bit of JavaScript in the HTML itself, which will periodically poll a PHP page. This PHP page should access the MySQL DB, retrieve the number, and send it back.
Here's Google AJAX tutorial which might help you: http://code.google.com/edu/ajax/tutorials/ajax-tutorial.html
Simpler PHP + AJAX examples:
http://simpletutorials.com/?path=tutorials/javascript/simple_ajax
http://www.w3schools.com/php/php_ajax_database.asp
Related
I'm currently only using PHP to take user submissions, put them in a database, and echo them out on a page using SQL to select from a table, such as comments. I need a system that will automatically update comments without refreshing the page like on YouTube. The less the user has to manually update, the better.
I want it to work pretty much exactly how YouTube and Twitter function, where it'll say "x NEW COMMENT(s)" and clicking that updates everything.
My teacher recommended a JQuery function, but I don't have any background in that language so I don't know where to begin looking.
I'm at a complete impasse. I will update this if you guys need additional information to aid in my search.
You are looking for AJAX
You will need a HTML page with jQuery/AJAX that calls another PHP page. In that PHP page you do the DB request and then ideally return the data as JSON so that your frontend part can display it to the user.
As every one says, AJAX is the way. You can find a simple blog I did on it here.
I am tying to put some user data from the database using php.
The database contains so many record and i am displaying it using mysql_fetch_row() and this gives me the fields of first row.
Now the problem is a have two buttons namely next and previous. And when a click next the fields in the next row has to be obtained the they should be inserted into page without loading the page once again. I am facing problem with this.
I am using php for server side programming and html, css for client side programming.
I think that no one will give you the answer. Too many to write. You need to read about ajax (this is the technology that will allow you to do some action without page reloading).
You need to write javascript(you can use some library like jquery) function which will open some php page with the data that you want and then update your site.
Here you have some nice tutorial:
http://www.w3schools.com/jquery/jquery_ajax_intro.asp
I want to create a page where people can insert some text, hit enter, and the text be stored in a MySQL database. I can do this, but I want to be able to load a page, enter a password, and see a list of all the info in said database, then whenever something is added to the database, it's added to the list on the page, without me needing to refresh the page or setup some javascript code to refresh the page every five seconds.
I believe Satya has it correct in suggesting that you use Ajax in order to refresh the data without refreshing the page. You can have it request updated information from a php script which queries your database for the data you wish to display, and then sets the elements on your page accordingly.
this is probably the best way for you to implement ajax calls using javascript
http://api.jquery.com/jQuery.ajax/
Or you an simly do it with the help of setInterval() function. You can call an html code in a div using
$('#id').html("<htmlcode></htmlcode>");
Example : http://jsfiddle.net/ipsjolly/995PJ/6/
I am currently using Jquery UI to display checkboxes, which right now, don't do anything!
you can see the current set up here: rickymason.net/letschat/main/home/
I am still trying to understand JSON, AJAX and Javascript...but i know they are required to make this work:
When the user checks one, or more of the checkboxes, I'd like it to refresh the thread list at the bottom of the page based on which list is checked.
I don't need exact code (though the more the merrier!), just a good outline on the process that needs to take place.
I'm using codeigniter, thus php and mysql. The thread list is generated based on a * query for the threads table. Then, it is filtered based on a session variable which contains all active filters (user input, AND i'd also like it to be selectable via the jquery select box).
Any help is greatly appreciated!
The magic word here is AJAX.
Use jQuery to bind to the events of the form elements
Send the event through AJAX calls to the server
Parse the response from the server and use javascript to update the page
I want to implement a sort (by name) function in my php web page. I know it's in simple Php. by submitting the page and take the request value and querying according to that value.
But I want to sort without red=refreshing the page. So I have studied about jquery and Ajax, in both of them there is no way to get the request value (i.e., sort=name). How I get that request value.
I am in serious situation. Please give me a way
If it's a table, you could use a plugin like datatables which does that (and much more by the way)
There IS a way to get URI query variables. I think you should use jQuery to do this as you will get the best results.
A query would look like:
$.get("ajaxtable.php", { sort: "name" },
function(data){
$('#tablecontainer').html(data);
}
);
What you need is a PHP script which generates just the table for you. Then you would attach the header links to javascript functions which make a query to your PHP script, and set the contents of the area the table belongs to the new table HTML which is sorted.
Alternatively, you could use javascript tables, whereby all information is loaded into the table and allows the client to sort using javascript. Look at http://datatables.net/ (jQuery datatables) for that.