user722769
user722769

Reputation: 177

why is only one row being returned from the mysql query

I have this query:

mysql_query( "SELECT tre.TrainerEducationID, tge.EducationName, tre.EducationNote
              FROM trainereducation tre
              INNER JOIN trainingeducation tge ON 
                (tre.EducationID = tge.EducationID)
              WHERE tre.TrainerID = '$id'" );

It apparently is only returning a single row, even though there are more than 2 rows in the TrainerEducation table.
Why is that?
Shouldn't it return more than one row?

Upvotes: 1

Views: 846

Answers (3)

Emil Vikström
Emil Vikström

Reputation: 91983

mysql_fetch_array does fetch one row only. Try doing it in a loop like this:

$all_rows = array();
while($row = mysql_fetch_array($result)) {
  $all_rows[] = $row;
}

Upvotes: 1

Ibu
Ibu

Reputation: 43850

Maybe your conditions don't match, try using left join instead for debugging and see what you get

Upvotes: 0

Halcyon
Halcyon

Reputation: 57723

Then use:

while ($row = mysql_fetch_array($result)) { // keep fetching until it returns false
    var_dump($row);
}

As posted on: http://php.net/mysql_fetch_array

Upvotes: 1

Related Questions