I am not sure the correct terminology for the process that I am trying to describe. I don't even know which platform is underlying the technique. If you understand my description, please give the link to the site(s) and or the keyword name of the process. I think it is done by AJAX, but I am not certain. I use php as the backend code, I just need to find a way to dynamically display the results. Please give suggestions. I forgot the name of the sites that use this, and my link history expired.
TIA
Description:
The page would have a search form and options. After the user submits, the search is initiated, and the results appear inside the dedicated result area. The page does not refresh, just the info inside the result area.
The display area will show 20 (or whatever) results (lines). There will be next, and previous buttons. If you hit next, the next set of results will display.
I am writing a code that generates 20 results for each display. There is no set number of results, so the results might have a start/first page, but do not have an end page.
Each time the user hits 'next', the program would generate/load new results. It would also store previous results, so that when a user hits 'prev', the previous results can instantly come up.
What techniques/program are theses?
Having recently handled pagination with Code Igniter (php framework), the following links might help you and anyone else out:
http://tympanus.net/jPaginate/
http://codeigniter.com/forums/viewthread/93045/
Usability is important and AJAX pagination introduces some important questions that need addressing regarding pagination, the following article will give some usability guidelines for displaying results in a table:
http://thedesignvanguard.com/crud-r-for-read
Code Igniter Prototype Framework Ajax Pagination:
http://codeigniter.com/wiki/AJAX_Pagination_with_CI_Pagination_Library/
Since we're using jQuery, we chose the following, Codeigniter jQuery framework for AJAX pagination
http://tohin.wordpress.com/2008/08/12/codeigniter-ajax-pagination/
http://tohin.wordpress.com/2008/10/07/codeigniter-ajax-pagination-exampleguideline/
It is not AJAX for sure.
Nobody uses AJAX for the pagination.
And there are about zillion pagination examples over internet
The only thing is never described in articles is how to persist search options for the other pages.
But it's simple enough: http_build_query() can help you
You need to have a GET/POST form submitted via AJAX which contains the fields in the search term and page number.
If you are going to set the page size to 20 results, page_num=4 will show results from 61-80 results.
Usually search results are GET instead of POST (Ex: See Google search results ) along with the page_number as another attribute and value.
#IVAN .. good to know that the library came helpful..
About that searching option; check the recent commit in github
http://github.com/neotohin/CodeIgniter-Ajax-pagination-Library there is an additional parameter added for searching.
I think the simple code in readme is enough for understanding the mechanism.
You could use datatables
https://datatables.net/
https://datatables.net/examples/data_sources/server_side.html
With this plugin using jquery also you could use server sided page request , you just have to handle the plugin post using Ajax.
post automatically sends row , page offset column, search criteria you just have to provide the json encode return
and the plugin automatically has library in featuring pagination, search sort number of rows per page and the table formatting.
Needed are jquery, and the plugin css and js for this to work
let me know if you understood my explanation.
thanks (=
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 have asked this question in a similar manner here before and got a mixed response.
Having done some more homework I feel the need to ask again as I am taking a far more logical view toward it.
I have a search box, I want to take the the query from the search submission, process it and return the result to an Iframe in another page.
Very much like a php email form, but with a twist.
Ideal Scenerio:
search box query > process the query( the query is sent to external server in a string and processed, then returned as a html page > page displayed in an Iframe on another page.
I would like any suggestions or example code would be good.
Only some suggestions as I've not ready code to show you here:
this seems to me the ideal situation to use AJAX.
BUT I'd create and use a box (with div tag) rather than using an iframe.
You should bind your searchbox submission with a function that make the ajax call to a script that process the search parameters and provide you with results.
Once results are ready, your function callback will make them appear in your box (modifying the inner html contents of the box).
I think MAYBE you could get same result with an Iframe but, personally, I don't like using frames.
Hope to have helped you.
Here for you a little ajax tutorial showing just something like the thing you need
First off I would like to say that I have done ample research on jquery pagination tutorials and scripts and the ones I have tried had worked, but just not the way I wanted them to.
What I am looking for is a jquery+php pagination that has 5 buttons. One for the first page, last page, next page, previous page, and manually enter a page to go to (which would also display the current page). I am new to pagination and have no idea how to integrate or alter current scripts, but I'm willing to learn as long as I can have the 5 buttons stated above and use php mysql queries. Thanks for the help!
UPDATE: I can do this with only php (would have to reload the page) but I do not know how to do this with jquery
UPDATE2: I figured out how to have the user manually input page number, but I still do not know how to do the other for buttons. For the next and previous buttons, I think I need to return the current page, but I have no idea how to do this :/
The trick is you use limit and offset parameters in your mysql query. Depending on what page number of the result you are serving, you can modify the ordered mysql query to fetch the result from that offset. It's pretty simple to work with that after you understand how to paginate in mysql queries.
In order to accomplish this you simply need to enable your application to make an ajax call to fetch the 'more info' results. That ajax call should take two parameters, an OFFSET and a LIMIT. Simply store these values locally in the application (via hidden elements, JS cookies, etc) to reference. Next time the 'more info' button is pressed you increment the OFFSET by the LIMIT and repeat.
NOTE: It's important that your query that is fetching the results is also using an ORDER BY. If you are relying on the server to order the results the same automatically you could potentially repeat results if the data is being updated often.
In the header of my website, I have a horizontal list of the 6 latest posts. Now I would like to add a "previous" button, which causes the content of this list to be replaced by the 6 posts before the ones that are currently displayed. The idea is that, if a user clicks "previous" often enough, he is able to thereby see all posts ever made.
Most of the tutorials for creating this always load ALL posts, and then simply stuff them into some jQuery-slider. However, since I have 100+ posts, this seems not the best approach (some users might actually never click "previous" at all so why waste resources loading them).
Could you please point me to a tutorial that explains how I can get the previous posts using php each time the "previous" button is clicked? (I'm using Wordpress btw)
The problem was solved without any tutorial, just with the help of a few stackoverflow threads. Now I have an awesome Post-Slider :)
If you rely on php for that, you'll need to refresh the page each time. I think you really want an AJAX solution.
You can build a PHP web service that
1) accepts some variable, such as the ID of the lowest post currently displayed
2) outputs XML or JSON of the six posts prior to that
Then, on your page, onclick of your previous button, send the variable, accept the response, and place each post as needed. .ajax and .load are some jQuery methods to look into
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/