Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I'm currently developing a module for Drupal 6 to output my webform entries to a table that can be filtered and searched.

I've got an AJAX callback function that returns my sql query but I can't figure out how to add line breaks as the data from each form field is in different rows in the database as per the webform module.

This is my callback function so far

function web_form_table_get_table($arg1){

$query =    "SELECT nid, sid, cid, no, data " .
            "FROM webform_submitted_data " .
            "ORDER BY sid desc, cid, no";

$queryResult = db_query($query);

while ($webformTable = db_fetch_object($queryResult)) {

    $items .= '<td>' . $webformTable->data . '</td>' ;

}

if ($items == '') {
    $items = "Your search yeilded no results.";
    }

    return drupal_json(array('products'=>$items));
    exit;

}

I've attempted to add some if statements to check if 'sid' (form reference) has changed and if so to add a line break but this just causes the site to crash.

My jquery is as follows:

 // $Id$
 Drupal.behaviors.web_form_table = function (context) {
 $('a.getTable:not(.getTable-processed)', context).click(function () {
 var updateProducts = function(data) {
  $('#divProducts').html(data.products);
}
$.ajax({
  type: 'POST',
  url: this.href,
  success: updateProducts,
  dataType: 'json',
  data: 'partNo=' + document.getElementById("partNo").value +
        '&worksNo=' + document.getElementById("worksNo").value +
        '&serialNo=' + document.getElementById("serialNo").value +
        '&transType=' + document.getElementById("transType").value
});
return false;
}).addClass('getTable-processed');

}

Has anyone got any ideas on how this should be done?

Help! Thanks.

share|improve this question
    
can you post your jquery? –  austin Aug 15 '12 at 13:39
    
jquery is as follows –  user9129 Aug 15 '12 at 14:33
    
Sorry added to main post for better visibility –  user9129 Aug 15 '12 at 14:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.