retrieve data from mysql using php and jquery - php

I have a menu, it contains multiple items, each menu item will retrieve data from the database.
I want to do it without the page refresh, I want like an area that will change when the user clicks on the menu link.
How should I send data to the php script and how should I get it from there and preview it on the page?
If you can send me any information, references or examples that will be great.
Thanks in advance.

I would start by reading some of the documentation from the jQuery website:
http://api.jquery.com/category/ajax/
This might also be of interest to you:
http://articles.sitepoint.com/article/ajax-jquery

Related

php html dynamically add to end of list items

I have some data on the server side in a database like Person Info.
I'd like to do the following when the user first views the page: show e.g 3 person info on list like placement.
I can do this by write query for read from database and write "for" in php
and write html code and echo to fill 3 list item.
Next now I need add a link like "more persons" below this tree output and when user clicks this link PHP will show other Persons Info at the end of previous 3 person info without refresh page or redirecting.
How can I do that?
This is an ajax job, you will need to pass the last id of the last person and get the next lot. Anyway ajax - so look into jquery - should make it an easier job.
What you need to use is ajax. I will suggest using jquery for ajax because it will let you get started quickly.
https://learn.jquery.com/ajax/
Hope this helps.

How to execute mysql_fetch_row() upon a button click

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

View live updates from MySQL database?

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/

Display search result page on back

I am developing a website in php (I am using codeigniter). On search by user I need to display list of products. Search result should give small description about the each product. Once the user clicks on more anchor I need to give full description about the product. Once user clicks back I need to be back to the search result page. I have used pagination. Any suggestion on how to carry out this task. Thanks in advance.
Indeed, this sounds like a job for our good friend Javascript. But not that much - simple history trick would be sufficient in my opinion. Resource:
http://www.javascriptkit.com/jsref/history.shtml
Example:
Go back 3 pages
This sounds like a job for our good friend Javascript. You could do this with a modal window that retrieves a page (such as /product/id/full_description) and displays the full description.
There are many modal window scripts out there that can do this. I am using jQuery and one called SimpleModal (http://www.ericmmartin.com/projects/simplemodal/) and it works well. I am using this since I am already using jQuery for many other things.
Here are some other examples:
http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/dhtmlmodal.htm
http://okonet.ru/projects/modalbox/index.html
http://www.huddletogether.com/projects/lightbox2/
http://orangoo.com/labs/GreyBox/
http://jquery.com/demo/thickbox/

How to browse every 5 records using MYSQL and jquery ajax calls

I am looking for solution where using jquery I want to display 5 records per page and need Next/Prev functionality. So when user click on next button or image it will fetch data from PHP, Mysql and displays it.
SO kind of pagination but using Next/Prev
Thanks & Regards,
web programmer
Your question is not very detailed, but I'll take a swing at it. Datatables is a great plugin for jQuery that will display records in a table. It supports pagination, with Next & Previous buttons. Check it out at www.datatables.net
You can see an example of the Next & Previous pagination here.
You can see an example of PHP serving data to datatables here.
If you are using jQuery, look at the tablesorter plugin (along with the pager plugin as well)

Categories