We want to have a user insert an account number and have invoice information be displayed that is stored in a MySQL database. Is there some sort of plug in, module or something that we should use or would it be simpler to just write a php script? We have ample SQL skills but less so in web design.

2 answers


You need to store new user-specific data? Just add fields through the core shipped profile module and maybe CCK?

You could probably add fields programmatic through a custom module.

Answered over 9 years ago by Jens Hedqvist
atroon 0

we want to display a table based on a single user input which could be used in a where clause such as customer number. As of now all I have been able to find to display a table is :

<?php echo show_table('blocks', 50);

function show_table($table = NULL, $rows_per_page = 20) { if (!$table || !db_table_exists($table)) {

  drupal_set_message(t('You must supply a valid database table name.'), 'error');

// We get the first (or only) part of the Primary key to be added to the sort sequence. $result = db_query("SHOW INDEX FROM {$table}"); $x = db_fetch_array($result); if ($x === FALSE) {

drupal_set_message(t("The '@table' table has no index defined. This is probably normal.", array('@table' => $table)), 'notice');
$first_key = NULL;

} else {

$first_key = $x['Column_name'];


drupal_set_title(t('@table Table Contents', array('@table' => ucwords($table)))); $output = '

'. t('Click on a column title to sort by that column.') .'

'; $rows = array();

// Now we get the column names from the table and build the header. $header = array(); $result = db_query("SHOW COLUMNS FROM {$table}");

while ($col_desc = db_fetch_array($result)) {

$header[] = array(
  'data' => ucwords(str_replace('_', ' ', $col_desc['Field'])),
  'field' => '`'. $col_desc['Field'] .'`',


// Get the data rows from the table. $select = "SELECT * FROM {$table}"; // Set it up so that the user can sort on any column, but the primary key will always be the last value to sort on. $select .= tablesort_sql($header) . ($first_key ? (', '. $first_key .' ASC') : NULL); // Do the query so that we can page the data. $result = pager_query($select, $rows_per_page);

while ($row = db_fetch_array($result)) {

$line = array();
foreach ($row as $key => $value) {
  // We use check_markup to apply our filters.
  $line[] = check_markup($value, FILTER_FORMAT_DEFAULT,TRUE);
$rows[] = $line;


// Build the displayable table. $output .= theme('table', $header, $rows); $output .= theme('pager', $rows_per_page); return $output; } ?> which nicely shows things in the drupal database but I don't want to use the drupal database or use the apache user which is proving difficult to get around. the ability to sort columns is very nice and I'd like to be able to do that with other tables. We're trying to make it as a quick reference tool.

Answered over 9 years ago by atroon