hi all
i have this query which joins three tables. but the result it shows me is not all correct (in PHP page). meaning, if i have 4 records (query result), it will only show me 3 records. it will start from second record instead of result record number 1
eg:
$sql = "SELECT DISTINCT tblA.id,tblA.name, tblA.rank,tblB.rankId,
tblB.rankDesc,tblB.dept,tblC.deptId,tblC,deptDesc
FROM tblA,tblB,tblC
WHERE tblA.id = '".$HTTP_SESSION_VARS["stuId"]."'
AND tblA.rank = tblB.rankId
AND tblB.dept = tblC.deptId";
$doSql = mysql_query( $sql ) or die( mysql_error() );
while( $x = mysql_fetch_array( $doSql ) )
{
echo $x["name"]."<BR>";
}
my 'should be' result:
Adam
Mary
John
Steve
but currently my result shows:
Mary
John
Steve
i use mysql_fetch_array() function to extract those data. it will start from Mary instead of Adam everytime. tried mysql_fetch_object() also but i got the same result.
to get those result in the 'should be' result, i used
echo mysql_result( $doSql, 0, "name")."<BR>";
echo mysql_result( $doSql, 1, "name")."<BR>";
echo mysql_result( $doSql, 2, "name")."<BR>";
echo mysql_result( $doSql, 3, "name")."<BR>";
and it showed correctly...
any ideas?