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
https://forums.phpfreaks.com/topic/85661-php-mysql-list-sorting/
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.

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.