A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearSort a mysql table using php,ajax and jquery - page 1
User InfoPosts
Sort a mysql table using php,ajax and jquery#1
Hello Everyone
Ok here is the deal i am building a messaging system by php,ajax,jquery and mysql i add the new message and i add in 2 rows now what i want to do is to send an ajax request to server and recieve an updated version of the table but sorted
So how can i do so

//here i add and call the message the message

function addMsg()
{
//alert(post);
$.get("db.php",$((form().serialize(),
function(data){
getMsg(data);},"html");
}


function getMsg(data)
{
alert(data);
$("#t1").append(data);
}
//php


	$sql="INSERT INTO -----

mysql_query($sql) or die(mysql_error());


$result = mysql_query("SELECT ----");

while($row = mysql_fetch_assoc($result))
{
echo "<tbody><tr><td>".""."</td><td>".$row["col"]."</td><td>".$row["col"]."</td><td></td><td></td><tr><td></td><td colspan=(4(>".$row["col"]."</td></tr></tbody>";
}


?>

//Now for sorting
//javascript

function sort()
{
$.ajax({
url: "sort.php",
dataType: "text",
success: function(data){
$("t1").text(data);
}

});

}


//php


$result = mysql_query("SELECT * FROM table ORDER BY col desc");

			while($row = mysql_fetch_array($result))
{
echo "<tbody><tr><td>"."&#8226;"."</td><td>".$row["col"]."</td><td>".$row["col"]."</td><td></td><td></td><tr><td></td><td colspan=(4(>".$row["col"]."</td></tr></tbody>";
}


?>

posted date: 2009-04-13 05:49:00


Re: Sort a mysql table using php,ajax and jquery#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-13 05:49:01


Re: Sort a mysql table using php,ajax and jquery#3
Use ORDER BY when you do the SELECT. Check this: http://dev.mysql.com/doc/refman/5.0/en/sorting-rows.html

posted date: 2009-04-13 06:21:00


Re: Sort a mysql table using php,ajax and jquery#4
It might make your question easier to read for everyone if you used a period once in a while. =]

posted date: 2009-04-13 06:41:00


Re: Sort a mysql table using php,ajax and jquery#5
Also, a few lines of your source code are formatted incorrectly. You need to put 4 spaces in front of "function getMsg(data)..." and "$result = mysql_query(..."

posted date: 2009-04-13 06:46:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.