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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP