Hi, I am looking to be pointed in the right direction. I have an admin panel that I am wanting to revamp. On one page “viewall.php” it pulls all of the rows from a database and puts them in a table. In this table it displays basic info about the record. The last column there is a link that takes that record to “viewpost.php?recordId=25” to view that record more in depth. In this file I have several link’s that allow an admin to edit or delete the post. Again taking that record to “editpost.php?recordId=25” or “deletepost.php?recordId=25”. This all works fine.
I am want in to change my site template to a jquery tab system. What I am wanting help trying to figure out is how I can accomplish this all on one php file without reloading the page. Can this be done? Any and all help is appreciated! Have a good day.
Well the simplest answer would be to use AJAX to load the tab when it would be brought to the forefront. It would still be calling editpost and deletepost and viewpost, but doe it in a way that seems to be without reloading the page.
Thank you starLion.
I have some code that is some what working now. But not sure if I ended up using the correct method. And one of the things I am still trying to make work with the method I am currently using is that the table is not populated until a header is clicked.
This is the code I am including on my tab on index.php
I dont think .load() does what you think it does. I’m going to flag this post for moving into the javascript forum; they’ll be better able to tell you how to achieve the effect you’re attempting.
As a side note, there’s a standard disclaimer we’re putting forward that as of PHP 5.5, mysql_ is deprecated and will be removed entirely in the future, so it’s recommended you move your code to the mysqli_ or PDO libraries. (mysqli_ is virtually identical to mysql_ in functions; at large, you can simply add the “i” and it should still work.)
On your index.php page, is there a reason you’re not pre-populating the table when you generate the page on the server?
Also, with not much extra effort, you could make the page functional even with JS disabled - just have your index.php page take an optional ‘sortby’ param in the URL, and render the table accordingly. For users with JS, your PHP code can detect if the request is via ajax and send only the markup for the table rows rather than rendering the whole page.
Thanks fretburner. Not sure why I didn’t have the table populated with a default query. I have the table working as I was expecting. And yes I had all of this done in PHP already before I started using jquery. I am only making these changes to learn JS. What I am not sure about now I how I can get the post to open in the the same id=“jsContent”.