Drupal-7

 
Exercises result

Create your module with info file. I named mine ac_exercise.module. Replace anything with ac_exercise with the name of your module
Here's my ac_exercise.info file:

name = Exercise
description = Exercise (ac_exercise)
core = 7.x
package = AC Modules

Here is my ac_exercise.module file:

<?php

function ac_exercise_menu()
{
$items['health/exercise'] = array(
'page callback' => 'ac_exercise',
'access arguments' => array('view exericse'),
'title' => 'Exercise',
'description' => 'Exercise',
'weight' => 2,
'type' => MENU_CALLBACK,
);

return $items;
}

/**
* Implements hook_perm().
*/
function ac_exercise_permission()
{
return array(
"view exercise" => array("title" => "View Exercise"),
"modify exercise" => array("title" => "Modify Exercise"),
);
}

function ac_exercise()
{
return drupal_get_form("ac_exercise_modify_form");
}

function ac_exercise_modify_form($form, &$form_state)
{
//TODO: Make this dynamic
$obj = new stdClass();
$obj->id = 1;
$obj->name = "Lat Pulldown";
$obj->weight = 50;
$obj->reps = 10;
$obj->sets = 3;

$obj2 = new stdClass();
$obj2->id = 2;
$obj2->name = "Mid Row";
$obj2->weight = 20;
$obj2->reps = 8;
$obj2->sets = 4;

$records = array($obj, $obj2);
//End of variables

$form['exercises'] = array(
'#type' => 'fieldset',
'#title' => t('Exercises'),
'#theme' => 'ac_exercise_exercises',
);

foreach ($records as $record)
{
$form['exercises']['exercises_name_' . $record->id] = array(
'#type' => 'textfield',
'#value' => $record->name,
'#size' => 20,
);

$form['exercises']['exercises_weight_' . $record->id] = array(
'#type' => 'textfield',
'#value' => $record->weight,
'#size' => 3,
);

$form['exercises']['exercises_reps_' . $record->id] = array(
'#type' => 'textfield',
'#value' => $record->reps,
'#size' => 3,
);

$form['exercises']['exercises_sets_' . $record->id] = array(
'#type' => 'textfield',
'#value' => $record->sets,
'#size' => 3,
);
}

return $form;
}

function ac_exercise_theme()
{
return array('ac_exercise_exercises' => array('render element' => 'form'),);
}

function theme_ac_exercise_exercises($variables)
{
$form = $variables['form'];
$rows = array();

for ($i = 1; $i <= 2; $i++)
{

$row = array();
$row[] = drupal_render($form['exercises_name_' . $i]);
$row[] = drupal_render($form['exercises_weight_' . $i]);
$row[] = drupal_render($form['exercises_reps_' . $i]);
$row[] = drupal_render($form['exercises_sets_' . $i]);
$rows[] = array('data' => $row, 'id' => 'exercise_' . $i);
}
$header = array(t('Exercise'), t('Weight'), t('Reps'), t('sets'));
$output = drupal_render_children($form);
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'id' => 'exercises_table', 'class' => 'form-item'));

return $output;
}

randomness