Page 1 of 1

Problems "Order BY"

Posted: Wed Jun 14, 2006 3:52 am
by antraxx
Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hi

can some one help me with this code? I've got a working WM TippGame (public download) but there's a bug in my ranking. Sometimes, the order is wrong...

My Code:

Code: Select all

$sql="SELECT * FROM members WHERE
        Name = '$_REQUEST[name]' AND Password = '$_REQUEST[password]'";
        $result=mysql_query($sql);
        $anzahl=mysql_num_rows($result);
        if ($anzahl == 1) {
          // Suche alle Tipps zu einem bestimmten Match
          $sql="SELECT * FROM tips WHERE
          MatchID = '$_REQUEST[matchid]' AND TipScore != '99' ORDER BY TipScore DESC";
//
          $result=mysql_query($sql);
          $anzahl=mysql_num_rows($result);
          if ($anzahl==0) {
            echo "
              Es konnte keine Rangliste für die Tipps dieses Matches aufgestellt werden.<br>
              Entweder sind die Tipps noch nicht ausgewertet oder niemand hat getippt.<br>";
          }
          $i=0;
          $tipscoreabove=-1;
          echo "<table border=0 cellspacing=1 cellpadding=0>";
          while ($row=mysql_fetch_assoc($result)) {
            // Suche zu jedem Tipp zusätzlich noch den Namen
            $sql2="SELECT * FROM members WHERE ID = '$row[MemberID]'";
            $result2=mysql_query($sql2);
            $row2=mysql_fetch_assoc($result2);
            // fürs Layout
            if ($tipscoreabove != $row[TipScore]) {$i++;}
            if ($i == 1) {$size=3; $color="#CC9900";}
            elseif ($i == 2) {$size=3; $color="#999999";}
            elseif ($i == 3) {$size=3; $color="#990000";}
            else {$size=2; $color="#000000";}
can anyone help me?


Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Jun 14, 2006 3:55 am
by JayBird
Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Jun 14, 2006 5:14 am
by twigletmac
When you say 'wrong', how exactly is the ranking incorrect? What type of field is TipScore?

Mac

Posted: Wed Jun 14, 2006 5:32 am
by antraxx
the order is sometimes the MemberID not TipScore...
TipScore is varchar(3)

thx for reply