hallo,
I want to use theme_table function to generate a table. In the table cells I want html input textfields () but I can't understand how I can do that.
my function is below:

function theme_my_module_table() {
    // Table header. Used as tablesort default
  $header = array(
    array('data' => t('Field 1'), 'field' => 'table.field1', 'sort' => 'asc'),
    array('data' => t('Field 1'), 'field' => 'table.field2'),
    array('data' => t('Field 3'), 'field' => 'table.field3')
  );
    $query = 'SELECT table.* FROM {table}';
    $result = db_query($query);
    if (db_num_rows($result) == 0) {
        $rows[] = array(array('data' => t('No data found.'), 'colspan' => 3));
    }
    else {
        $rows = array();
        while ($row = db_fetch_object($result)) {
            $rows[] = array($row->field1, $row->field1, $row->field1);
        }
    }
    $output = theme('table', $header, $rows);
    return $output;
}

insteda of $rows[] = array($row->field1, $row->field1, $row->field1); I would like to output for example ).

any idea?
thanks

Comments

fivepoints’s picture

excusme I didn't used "code" feature in the last sentence.
I wanted to say:
instead of $rows[] = array($row->field1, $row->field1, $row->field1); I would like to output for example <input type="name[]" value="the_value_of_a_mysql_table_field" />).

fivepoints’s picture

I think I've found a solution. I've replaced this code:

$rows[] = array($row->field1, $row->field2, $row->field3);

with:

$rows[] = array(
  array('data' => '<input type="text" name="test1" value="'.$row->field1.'" />'),
  array('data' => '<input type="text" name="test2" value="'.$row->field2.'"  />'),
  array('data' => '<input type="text" name="test3" value="'.$row->field3.'"  />')
);