使用MySql查询和PHP的不同结果[关闭]

$sql=Select A.a,B.b,b,C.c

from A,B,C 
group by 
A.a, B.b,C.c
order by A.oder_nr,A.a

$row_Sql= mysql_query($sql,$db) or die (mysql_error());
$record_set=  mysql_fetch_assoc($row_Sql);
$totalRows_$row_sql=mysql_num_rows($row_Sql);
$A=''
$B=''
while ( $record_set = mysql_fetch_assoc($row_Sql) ) 
{
   if ( $A != $record_set[ 'A' ] ) 
   {

       $A = $record_set[ 'A' ];

       echo "<h2>$A</h2>";

   }
   if ( $B!= $record_set[ 'b' ] ) 
   {

       $B = $record_set[ 'b' ];

       echo "<h3>$B</h3>";


   }
   echo "<li><a href=\"Detail.php?A_id=".$record_set['A_id']. "\">";
   echo $record_set['c'];
  echo $record_set['d']; ?></br></a></li>

   <?php } ?>

Using Sql query alone returns the complete result but using it with the php code always removes the first result.the query returns for example 1,2,3,4 but the php starts from 2,3,4. Any idea?

You're calling $record_set= mysql_fetch_assoc($row_Sql); once above the loop. This will effectively trim the first row off the resultset.

You also appear to be using variable variables, not sure if that's intentional or a typo:

while ( $record_set = mysql_fetch_assoc($$row_Sql) ) 
//                                      ^---------- variable variables!