Sort using php and jquery

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sarah aziz
    New Member
    • Sep 2007
    • 31

    Sort using php and jquery

    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
    Code:
    Jquery
    	function sort(tableHeader,sortDir)
    		{
    			$.ajax({
    			  url: "sort.php",
    			  type:"get",
    			  data: "tableHeader="+tableHeader +"&sortdirection="+sortDir,
    			  success:function(data){		
    			  $("#t1").html(data);
          	
    	          }
    			});
    		}
    
    php
    $table_Header=$_GET['tableHeader'];
    	$sort_Dir=$_GET['sortDir'];
    	
    if ($table_Header == 'From')
    {
        $sort_By = 'player_name';
    }
    else if ($table_Header == 'To')
    {
        $sort_By = 'player_name';
    
    }
    else if ($table_Header== 'Gr')
    {
        $sort_By = 'grp_abr';
    }
    
    	if (isset($sort_Dir) && $sort_Dir == 'DESC') 
    	{
    	    $sort_Dir = 'DESC';
    	} 
    	else 
    	{
    	    $sort_Dir = 'ASC';
    	}
    	
    	$str = stripslashes('From');
    echo $sortBy;
    $result = mysql_query("SELECT * FROM messages,Player  
    					   where player_id = from_user
    					   ORDER BY player_name ".$sort_Dir);
    echo "<thead>
    				<tr>
    				<th  style='color:royalblue;'>•</th>
    				<th  align='center'>Time</th>
    				<th align='left' onClick='sort('From',$sort_Dir);'>De:</th>
    				<th align='left'>To:</th>
    				<th align='left'>Gr</th>
                    </tr>
                 </thead> ";
    
    		while($row = mysql_fetch_array($result))
    		  {	 
    		
    	echo "<tbody>
    		  <tr class='highlight'>
    		  <td width='30' align='center' style='color:royalblue'>"."•"."</td>
    	      <td width='70' align='left'>".$row["Time_Date"]."</td>
    		  <td width='600' align='left'>".$row["player_name"]."</td>
    		  <td width='600' align='left'></td>
    		  <td width='100' align='left'></td>
    		  <tr class='highlight'>
    		  <td></td>
    		  <td colspan='4'>".$row["msg_desc"]."</td></tr>
    		  </tbody>";
    			   }
    First time works and then later tells me that From is undefined
    Last edited by NeoPa; May 4 '09, 12:26 PM. Reason: Please use the [CODE] tags provided
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    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

    Comment

    • sarah aziz
      New Member
      • Sep 2007
      • 31

      #3
      Sorry

      I am so sorry i am still not used to your site FORGIVE ME!

      Comment

      • sarah aziz
        New Member
        • Sep 2007
        • 31

        #4
        Sorry quick Q what is the oho side

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32668

          #5
          Originally posted by sarah aziz
          Sorry quick Q what is the oho side
          I can only assume Linq was referring to the other side. Probably just a humourous reference.

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            Originally posted by NeoPa
            I can only assume Linq was referring to the other side. Probably just a humourous reference.
            I often mistype PHP as OHO. :D

            Comment

            • Markus
              Recognized Expert Expert
              • Jun 2007
              • 6092

              #7
              You have no javascript function From(). That is why the Javascript fails.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32668

                #8
                Originally posted by Markus
                I often mistype PHP as OHO. :D
                That never occurred to me Markus.

                & Thanks for stepping in :)

                Comment

                Working...