hi,
i want to display some values in a table.
What is the syntax to create a table in drupal?

Thank u

Comments

dman’s picture

Set your input format to 'full html'
Turn off your WYSIWYG editor
Paste normal HTML syntax.

If you want to code PHP instead,
set your input format to 'PHP Code'
Turn off your WIYSIWG
Read the API docs on 'theme_table()'

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/

gareth_w’s picture

and then just use normal HTML syntax. Works fine for me.

Don't know if there is a BBCode euqivalent for this (and not sure you'd want one).

The alternative is to install a WYSIWYG editor with a table tool, but that's using the proverbial sledgehammer to crack the nut.

Gareth

vaishnavig’s picture

i do not want to paste my html code in the body....
i want to create a table through code in .module file just like we create other fields e.g
$form['name']=array(
'#type' => 'textfield',
'#title' => t('Name '),
);

can anybody tell me the syntax for that?

dman’s picture

Read the instructions for theme_table().
Although it's better to learn from examples.
Unfortunately I can't think of any really simple examples... Try searching!

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/

vaishnavig’s picture

thank u ......i'l chk that out

itpaul’s picture

$table = "<table>
                  <tr><td>1-1 tableData</td><td>1-2 tableData</td></tr>         
                  <tr><td>2-1 tableData</td><td>2-2 tableData</td></tr>
                </table>";

$form['table'] = array(
    '#title' => $table,
    '#type' => 'item'
);

produces

1-1 tableData 1-2 tableData
2-1 tableData 2-2 tableData
ankurgupta510’s picture

If you mean database table then you can access your database and insert the values inside the tables directly . Else there is a module for this purpose http://ftp.drupal.org/files/projects/dba-5.x-1.x-dev.tar.gz though it is underdeveloped .

Thanks

vaishnavig’s picture

i want to create a table to display some values in table format.

rimma’s picture

same as title

vaishnavig’s picture

thank u all for ur reply
the problem is solved

$output.=echo "<table><tr>";
$output.=echo"<td>bbgb</td>";
$output.=echo"</tr></table>";
drupal_set_message($output);
dvkd’s picture

Hi Vaishnavig

I tried this code:

$output.=echo "

";
$output.=echo"

";
$output.=echo"

bbgb

";
drupal_set_message($output);

but it showed parse error , what could be the reason?

thankyou

bangdel’s picture

if you are only trying to print the text, then remove echo from your code.
that way your string will simply get concatenated in the $output variable and it will get printed with the drupal_set_message.

selvain’s picture

$output= "<table><tr>";
$output.="<td>bbgb</td>";
$output.="</tr><tr>hi</tr></table>";
drupal_set_message($output);
chetan-singhal’s picture

For this you should use table theme.
For detail you can read this
table theme api

I am giving you an example for this-

<?php
$table_header=header('Name','Type');
$result_row=array( 
                               array('test','test1'),
                               array('test','test1'),
                               array('test','test1'),
                               )
$output=theme('table', array('header' => $table_header,
			  'rows' => $result_row,
			  'empty' => 'No records found!!',
			  'attributes' => array('id' => array('table_id'))));
?>

chetan