By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,610 Members | 1,989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,610 IT Pros & Developers. It's quick & easy.

Sort using php and jquery

P: 31
Hello all
i have a problem and i want to solve it
I am sorting data from mysql by php and jquery and something isn't right i don't know what here is the code and i need urgent help
Expand|Select|Wrap|Line Numbers
  1. Jquery
  2.     function sort(tableHeader,sortDir)
  3.         {
  4.             $.ajax({
  5.               url: "sort.php",
  6.               type:"get",
  7.               data: "tableHeader="+tableHeader +"&sortdirection="+sortDir,
  8.               success:function(data){        
  9.               $("#t1").html(data);
  10.  
  11.               }
  12.             });
  13.         }
  14.  
  15. php
  16. $table_Header=$_GET['tableHeader'];
  17.     $sort_Dir=$_GET['sortDir'];
  18.  
  19. if ($table_Header == 'From')
  20. {
  21.     $sort_By = 'player_name';
  22. }
  23. else if ($table_Header == 'To')
  24. {
  25.     $sort_By = 'player_name';
  26.  
  27. }
  28. else if ($table_Header== 'Gr')
  29. {
  30.     $sort_By = 'grp_abr';
  31. }
  32.  
  33.     if (isset($sort_Dir) && $sort_Dir == 'DESC') 
  34.     {
  35.         $sort_Dir = 'DESC';
  36.     } 
  37.     else 
  38.     {
  39.         $sort_Dir = 'ASC';
  40.     }
  41.  
  42.     $str = stripslashes('From');
  43. echo $sortBy;
  44. $result = mysql_query("SELECT * FROM messages,Player  
  45.                        where player_id = from_user
  46.                        ORDER BY player_name ".$sort_Dir);
  47. echo "<thead>
  48.                 <tr>
  49.                 <th  style='color:royalblue;'></th>
  50.                 <th  align='center'>Time</th>
  51.                 <th align='left' onClick='sort('From',$sort_Dir);'>De:</th>
  52.                 <th align='left'>To:</th>
  53.                 <th align='left'>Gr</th>
  54.                 </tr>
  55.              </thead> ";
  56.  
  57.         while($row = mysql_fetch_array($result))
  58.           {     
  59.  
  60.     echo "<tbody>
  61.           <tr class='highlight'>
  62.           <td width='30' align='center' style='color:royalblue'>".""."</td>
  63.           <td width='70' align='left'>".$row["Time_Date"]."</td>
  64.           <td width='600' align='left'>".$row["player_name"]."</td>
  65.           <td width='600' align='left'></td>
  66.           <td width='100' align='left'></td>
  67.           <tr class='highlight'>
  68.           <td></td>
  69.           <td colspan='4'>".$row["msg_desc"]."</td></tr>
  70.           </tbody>";
  71.                }
First time works and then later tells me that From is undefined
May 3 '09 #1
Share this Question
Share on Google+
7 Replies


missinglinq
Expert 2.5K+
P: 3,532
You've inavertantly posted this in the Access side of the form, so I've moved it over to the oho side.

Welcome to Bytes!

Linq ;0)>

Moderator
May 3 '09 #2

P: 31
I am so sorry i am still not used to your site FORGIVE ME!
May 3 '09 #3

P: 31
Sorry quick Q what is the oho side
May 3 '09 #4

NeoPa
Expert Mod 15k+
P: 31,602
@sarah aziz
I can only assume Linq was referring to the other side. Probably just a humourous reference.
May 5 '09 #5

Markus
Expert 5K+
P: 6,050
@NeoPa
I often mistype PHP as OHO. :D
May 5 '09 #6

Markus
Expert 5K+
P: 6,050
You have no javascript function From(). That is why the Javascript fails.
May 5 '09 #7

NeoPa
Expert Mod 15k+
P: 31,602
@Markus
That never occurred to me Markus.

& Thanks for stepping in :)
May 6 '09 #8

Post your reply

Sign in to post your reply or Sign up for a free account.