Displaying and selecting data from a database in a module I have a database table (gpx_api) with the following fields:

runID   userID  score   distance    pace    speed   gpx_path    missionID   startTime   duration 


I want to display all of these fields from within a module. 

I have searched a lot on stack and I got until here:

   $query = db_select('gpx_api', 'run')
     -&gt;fields('run')
     -&gt;condition('runID', $firstparameter, '=')
     -&gt;execute()
     -&gt;fetchAssoc();


Do I only select the row where runID = $firstparameter like this?

This should only return one result. Now how can I display the fields one by one? 

$query-&gt;distance 


will not work.

I also tried 

foreach($query as $result2){
 $result .="DISTANCE";
$result .= $result2-&gt;distance;
  }


This strangely enough gave a lot of results and errors. 

I am sure there is a very simple way, but I am not familiar with the drupal API.

--Update

a var_dump of query gives me: 

array(10) { ["runID"]=&gt; string(1) "2" ["userID"]=&gt; string(1) "1" ["score"]=&gt; string(2) "10" ["distance"]=&gt; string(3) "200" ["pace"]=&gt; string(1) "7" ["speed"]=&gt; string(1) "8" ["gpx_path"]=&gt; string(0) "" ["missionID"]=&gt; NULL ["startTime"]=&gt; NULL ["duration"]=&gt; NULL } 


so it is just about displaying the array. Shouldn't $query->distance  work then? Yet if I try it, I get this error:

Notice: Trying to get property of non-object in epicrun_mymenu_page_callback() (line 62 of /home/suneesto/public_html/addons/epicrunapp.com/sites/all/modules/epicrun/epicrun.module).
Basic php error, it's $query['distance']