How to add an edit and delete button to a custom html table? I've a db_select to fetch data from sql table, and $output .= theme('table'...) to generate an html table to display these data in columns. My question is, how can I add edit and delete buttons to each row?

Also, given initially these data are stored in the sql table from dropdowns, how can I redirect to the link containing the dropdowns load again and if for example I edit a row which has data from formID=5, each dropdown then shows the corresponding data for this ID, and allow me to modify accordingly to save again to the same sql table, and update the html table's view?

Example of my current sql is:

db_select('mytable')
        -&gt;fields('mytable', array('formID', 'field1', 'field2'))
        -&gt;execute();
$query = db_select('mytable', 'n')
    -&gt;fields('n')
    -&gt;execute();
  $rows = array();
  while($data = $query-&gt;fetchAssoc()){
  // Fill the table rows
    $data['operation'] = l(t('Delete'), 'admin/mid-modules/component/' . $data['cid'] . '/delete');
    $data['operation'] .= "|";
    $data['operation'] .= l(t('Edit'), 'admin/mid-modules/component/' . $data['cid'] . '/edit');
    $rows[] = array('data' =&gt; $data, 'style' =&gt; 'word-break:break-all;',);
  }

  // Prepare table header
  $header = array( t('S.No'),t('Component Name'));
  // Output of table with the paging
  $output = theme_table(
    array(
      "header" =&gt; $header,
      "rows" =&gt; $rows,
      "attributes" =&gt; array(),
      "sticky" =&gt; true, // Table header will be sticky
      "caption" =&gt; "",
      "colgroups" =&gt; array(),
      "empty" =&gt; t("Table has no row!") // The message to be displayed if table is empty
    )
  );
  return $output;
//following menus that delete or edit your selected content

    $items['admin/mid-modules/component/%ctools_js'] = array(
    'page callback' =&gt; 'popup_callback',
    'page arguments' =&gt; array(3),
    'access callback' =&gt; TRUE,
    'type' =&gt; MENU_CALLBACK,
    'file' =&gt; 'popup.inc'
  );
 $items['admin/mid-modules/component/%/delete'] = array(
    'title' =&gt; 'Delete Component item',
    'page callback' =&gt; 'delete_me',
    'page arguments' =&gt; array('delete_component_record_comfirm',3),
    'access arguments' =&gt; array('administer users'),
    'type' =&gt; MENU_CALLBACK,
    'file'=&gt;'delete_record.inc',
  ); 

/**
 * Delete  Record Confirmation ------------------------------------
 */
function delete_component_record_comfirm($form, &amp;$form_state, $cid){
   // print_r($cid);exit;
 $form['delete'] = array(
    '#type' =&gt; 'value',
    '#value' =&gt; $cid,
  );
  return confirm_form(
    $form,
    t('Are you sure you want to delete this?'),
    'admin/mid-modules/component/'. $data['cid'],
    t('This action cannot be undone.'),
    t('Delete'),
    t('Cancel')
  );
}
/**
 * Delete Survey Record Function
 */
function delete_component_record_comfirm_submit($form, &amp;$form_state) { 
  $record = $form_state['values']['delete'];
  if ($record ) {
    $num_deleted = db_delete('mid_components')
      -&gt;condition('cid', $record )
      -&gt;execute();
    drupal_set_message('The record has been deleted!');
  }
  $form_state['redirect'] = "admin/mid-modules/component";
}