0

I'm really having a hard time getting my head around the DB abstraction layer.

I've got a simple 2 column table and I'd like to output the values in the at table to a template. I've seen plain php/mysqla like this:

$result = db_query_range('SELECT age, savingvalues FROM {savingvalues} 21, 65);
while($row = mysql_fetch_array($result))
{
echo $row['age'] . " " . $row['factor'];
echo "<br />";
}

and it's something like this I'd like to emulate, even if I have to strongarm it a bit, can anyone please help me figure this out? I'm in drupal 6

Thanks!

Steph

1 Answer 1

1

Use this table theming, next code created from comments below with some fixes:

  $header = array(
    array('data' => t('Age'), 'field' => 'age', 'sort' => 'asc'),
    array('data' => t('Savings'), 'field' => 'savingvalues'),
  );

  $result = pager_query("SELECT age, savingvalues FROM {savingvalues} " . tablesort_sql($header), 30);

  $data = array();
  while ($row = db_fetch_array($result)) {
    $data[] = $row;
  }
  $output .= theme('table', $header, $data);
  $output .= theme('pager');
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.