Jump to content

php, mysql list sorting


gurechan

Recommended Posts

I have a list on my website that is generated from a mysql database with php. The order of this list can be changed by using up and down arrows (images that I've created) and a php script that I've written.

 

The only minus to this is that when an arrow is clicked to move a list item the page needs to re-load to call the php script.

 

I would like to use an Ajax function to call the php script instead, but can't seem to find a good example/tutorial on the web. Can anyone help me out or point me in the right direction.

Link to comment
Share on other sites

start here:

 

http://www.ajaxfreaks.com/tutorials/1/0.php

 

Set-up your html like this:

 

<!--Add Your Sorting Arrow/Function Here Or Where Ever; As Long As It Is Outside The "ajaxTest" DIV-->
<div id="ajaxTest">
<!--Database Results Here-->
</div>

<a href="javascript:void(0)" onclick="sendRequest('asc')">Sort Ascending</a>

 

You will need to create a php page that displays just the results from your database that you want updated. Plus the html formating; so the updated data will display as you wish it display within the page (ie. table, div, td, tr). In the tutorial that I linked above; they named this php page "myphpscript.php".

 

You can also add more then one variable to your AJAX query string; if you need to know how to do this, let me know and I will post an example of how to do that.

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.