Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 245565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:05:58+00:00 2026-05-11T21:05:58+00:00

What is wrong with this code it works the first time then when I

  • 0

What is wrong with this code it works the first time then when I build the header again an error occurs saying From is undefined

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>";
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T21:05:58+00:00Added an answer on May 11, 2026 at 9:05 pm

    here following my observations, after having a look at your source code.

    sort.php:12 >>> the $_GET array element for sort direction is mistyped: you call it $_GET["sortDir"] while the javascript sort() function composes the ajax request with that variable in querystring called ‘sortdirection’.

    sort.php:28 >>> You don’t need to reverse sort order here, as your javascript function sortDirection() already does it. So, comment lines from 28 to 35 and at line 44 do not use the php variable $sort_Dir, but the javascript variable sortDir instead.

    user.php:48 >>> the comparison to determine current sort order is made against the string literal "Desc", while generally you use "DESC" as a value for this variable, so the first try was fine but the second simply does nothing, as "DESC" is different from "Desc" in Javascript, due to binary comparison between strings. So change "Desc" to "DESC" into your sortDirection() function.

    This should get your stuff working.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whats wrong with the following c# code? Compiler reports this error: Inconsistent accessibility: parameter
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I came across this code today AsyncInvoke(OnTimeMessageTimer, (object)null, (ElapsedEventArgs)null); Is there anything wrong with
This snippet of Perl code in my program is giving the wrong result. $condition
There's something wrong with my code or I'm just not understanding this fully. I
I've used stackoverflow many a time to solve my problems (code related!) but this
What's wrong with this query: INSERT INTO Users( weight, desiredWeight ) VALUES ( 160,
Am I doing something wrong is this a known issue with the ASP.NET MVC
Does anyone know what is wrong with this query? SELECT DISTINCT c.CN as ClaimNumber,
Can someone tell what is wrong with this query? sqltext = SELECT utyp, count(*)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.