I am trying to use the jQuery pagination plugin with my PHP/MySQL website – It appears I have to either use Ajax or use PHP to write the jQuery pagintion header so I can control the $offset and $limit, in order to control the pagination –
What is the best way to combine javascript, PHP and MySQL so that they can communicate with eachother? Here is my PHP page and SQL
You could have a seperate standalone page for the PHP which grabs the query and call it using $.ajax - could use a GET method to send the limit and offset, and in the standalone PHP page use $_GET[‘offset’] and $_GET[‘limit’] to grab the query.
Roughly the same as what your php snippet has, except using $_GET values to query the database, and just echo the output in there and then grab the html with $.ajax callback. I’m a little weary from replying to threads all day, but if someone else doesn’t reply I may make a little sample.
Yea I read it last night after you posted it – I continued graphic design/layout on the project and waited until this morning to give it a look.
If it means anything, I slept better last night because you slept worse Thanks
EDIT: Also I see you inserted PHP tags inside your javascript… funny, I tried this, but it caused the script to break and I assumed it wasn’t possible-- expecting client-side scripting to be able to be dynamic with server-side scripting… i suppose that is the reason for Ajax. Am I correct?
This would break if you tried to do it in an external .js file which was sent as application/javascript, or whatever the Content-Type http header for JS is, unless you made some .php page that was sent as js, you can’t do it like that.
However, if you do it in a page which is parsed as php, such as .php then it’s fine, because it’s just outputting text, the same as typing bare HTML.
If you tried to do this in an .html page which wasn’t properly configured by the server to be parsed as php, then it probably wouldn’t work either and break on the ‘<?’.
AJAX is just a buzzword used to mean a variety of techniques which prevent the page from fully reloading, and can include using javascript to insert an iframe to give an “ajax” effect, the proper “ajax” way really is to create a new XMLHttpRequest object in a modern browser and open up a new http request.
To have pagination at the top and bottom of the search results, could I duplicate and rename the pagination div and double-up on the javascript call to the new div id?
I guess i was misunderstood … you answered my last topic about the pagination and you told me to use DataTables … but, i’m still trying to find a way how to add LIMIT to tablesorter and its plugin pager
I did the pagination and I used the script, you gave, at the bottom of my table and it works… the only problem is to limit the [SELECT] results for big number of lines on the sql table (so the program don’t load thousands of lines!)
Tablesorter and the paginator cannot work in the way you require.
They are designed to only sort and paginate the complete dataset that is on the page.