[help] color changing in php databse codes

Discussion in 'PHP' started by pratik, Nov 7, 2006.

  1. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #21
    and the problem is??? :)
     
    daboss, Nov 24, 2006 IP
  2. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #22
    ah... ok, i understand now...

    change:
    $query  = "SELECT * FROM addetail order by " . $_GET['column_id'];
    Code (markup):
    to:
    
    if($_GET['column_id'] != "") {
      $query  = "SELECT * FROM addetail order by " . $_GET['column_id'];
    }
    else {
      $query  = "SELECT * FROM addetail";
    }
    
    Code (markup):
    that should do it. ;)
     
    daboss, Nov 24, 2006 IP
  3. pratik

    pratik Notable Member

    Messages:
    2,306
    Likes Received:
    114
    Best Answers:
    0
    Trophy Points:
    200
    #23
    hey thankz again..the errors have gone now...

    but now the sorting is not workin... i mean the links are there but nothin happens when i click it...;(
     
    pratik, Nov 24, 2006 IP
  4. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #24
    post the page code...
     
    daboss, Nov 24, 2006 IP
  5. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #25
    sorry... my mistake - i'm really getting old...

    it should be:
    
    if([B][COLOR="Red"]$_GET['sort'][/COLOR][/B] != "") {
      $query  = "SELECT * FROM addetail order by " . [B][COLOR="Red"]$_GET['sort'][/COLOR][/B];
    }
    else {
      $query  = "SELECT * FROM addetail";
    }
    
    Code (markup):
     
    daboss, Nov 24, 2006 IP
    pratik likes this.
  6. pratik

    pratik Notable Member

    Messages:
    2,306
    Likes Received:
    114
    Best Answers:
    0
    Trophy Points:
    200
    #26
    it worked

    thankz a ton.... :)
     
    pratik, Nov 24, 2006 IP
  7. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #27
    good to know :)

    and if you want the default page to sort by a certain field, you can try this:

    
    if($_GET['sort'] != "") {
      $query  = "SELECT * FROM addetail order by " . $_GET['sort'];
    }
    else {
      $query  = "SELECT * FROM addetail order by [B][COLOR="Red"]default_column[/COLOR][/B]";
    }
    
    Code (markup):
    replace default_column with the column you want to sort by default... ;)
     
    daboss, Nov 24, 2006 IP