douli1872 2015-06-23 12:38
浏览 46

编写MySql查询以返回列表表单

I have a drupal 6 installation with a bunch of webforms i need my users to complete.

My aim to to show a list of webforms in a table with submission dates and a col stating Complete or Not Complete.

This is where im at... I thought it was working until i submitted the forms as a test user and the table changed for everyone as NULL is no longer found once the form has been submitted by anyone.

I pretty much want to search and list all forms with SSOW in the title that exist and show if the current logged in user has completed them or not. I tried to achive this with views before i went down this route, but no luck there either

thanks in advance for anyone who might take a look

$sql = "SELECT node.nid AS 'page', node.title AS 'webform',
IFNULL(FROM_UNIXTIME(webform_submissions.submitted), '') AS 'subdate',
IF(webform_submissions.submitted IS NULL, 'NOT COMPLETED', 'COMPLETED')
AS 'status'
FROM node
LEFT OUTER JOIN webform_submissions ON node.nid = webform_submissions.nid
LEFT OUTER JOIN users ON webform_submissions.uid = users.uid
WHERE node.title LIKE '%SIGNOFF%' AND node.type LIKE 'webform' AND  
(webform_submissions.uid IS NULL OR webform_submissions.uid LIKE
'$user->uid')";

$res = db_query($sql);
$table_rows = array();
while ($row = db_fetch_object($res)) {
$table_rows[] = array(
  'data' => array(
// Column 1
'Webform'   => array('data'  => l($row->webform, 'node/' .  $row->page), 'class' => 'col-title', ),
// Column 2
'Date Submitted' => array('data'  => $row->subdate, 'class' => 'col-submitted',),
// Column 3
'STATUS'  => array('data'  => $row->status, 'class' => 'col-status',),
  // Row attributes
  'id'    => 'articles-row-' . $row->nid, 'class' => 'articles-row');
}

// Format and print out the table.
return theme('table', $table_header, $table_rows, array('id'      =>    
'table-articles', 'class'   => 'articles' ));
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 matlab实现基于主成分变换的图像融合。
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料
    • ¥15 使用R语言marginaleffects包进行边际效应图绘制
    • ¥20 usb设备兼容性问题
    • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊