programming.name Posted April 3, 2010 Share Posted April 3, 2010 Hi, I am currently learning MySQL and PHP and I wonder if it is possible to display contents from database without reloading a page using PHP script only. Please consider the following situatioin. There is a table named 'ta' in the database named "db". And the table has the following contents. ta ----------------- site | score ----------------- google | 99 ----------------- yahoo | 98 From this I can dispaly the score fairly easily using the following script: $db_conn = new mysqli('localhost', 'username', 'password', 'db'); $query = 'select * from ta ' ."where name='$site'"; But it has to reload the page. If you know how to do this without page reloading please provide me some code. Thanks. Quote Link to comment Share on other sites More sharing options...
beta0x64 Posted April 3, 2010 Share Posted April 3, 2010 Well, not really... PHP stands for Post Hypertext Processor, meaning that it already figures out all the results of your code before being fully loaded, so you're right in saying that it can not do it without reloading the page. It basically is just HTML by the time it gets to your browser. But, there's good news! With AJAX, we can do this by using Javascript to load the contents of a page and add it to the currently existing DOM. For super duper ease, I recommend using jquery. http://api.jquery.com/load/ Quote Link to comment Share on other sites More sharing options...
gamblor01 Posted April 5, 2010 Share Posted April 5, 2010 Someone else just asked this very same question a few days ago: http://www.phpfreaks.com/forums/index.php/topic,292404.0.html You can look at that post and see my response or you can go directly to the thread that I started about this: http://www.phpfreaks.com/forums/index.php/topic,287155.0.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.