Drupal 7数据库的单选按钮值不起作用

时间:2014-09-17 05:28:53

标签: drupal-7 drupal-modules drupal-forms

添加文本框,单选按钮和提交按钮工作正常..

enter code here:

' $ form = array();

              $form['name'] = array(
             '#title' => 'Your Name',
              '#type' => 'textfield',
                '#size' => '30',
                    );  

                 $active = array(0 => t('Blog-Url'), 1 => t('Twitter-Name'));

             $form['settings']['active'] = array(
                '#type' => 'radios',
                 '#title' => t('Enter nature of the name'),
                '#default_value' => isset($node->active) ? $node->active : 1,
                '#options' => $active,
                  '#description' => t('Enter nature of the name, and characteritics.'),
                    );

                    $form['submit'] = array(
                     '#type' => 'submit',
                   '#value' => 'Submit',        
                       );

                      return $form;'

//单击“提交”按钮时,操作将发生并插入到无法正常工作的数据库中。

`function sform_add_form_submit($ form,$ form_state){

                 $name = trim($form_state['values']['name']);   
                     $formwem= $form_state['values']['settings']['active'];
                $query = "INSERT INTO twittername (`name`,'Blogurt','Twitter_name')                                                    VALUES ('%s','%s','%s')";
                    $result = db_query($query, $name, $formwem ); ` 

请帮助我....

1 个答案:

答案 0 :(得分:0)

尝试将查询重写为:

$name = trim($form_state['values']['name']);   
$formwem = $form_state['values']['settings']['active'];

$result = db_query("INSERT INTO twittername (name, Blogurt, Twitter_name)                                             VALUES (':name',':blogurt',':twitter_name')", array(':name' => $name, ':blogurt' => $formwem, ':twitter_name' => $formwem));

虽然我不确定哪个表单字段填充了两列BlogurtTwitter_name。你能解释一下吗?