开发者

Write form API values to database

开发者 https://www.devze.com 2023-02-15 21:43 出处:网络
I want to write Drupal F开发者_开发百科orm value made from API Form, to my database with the following code:

I want to write Drupal F开发者_开发百科orm value made from API Form, to my database with the following code: Into my database only appears 1 and nothing more. What's wrong? Thanks!

$sql= "INSERT into {test} (id, studiejaar, opleiding, soortStage,
        stageplaats,periodes)VALUES(1, '%s', '%s', '%s', '%s', '%s')";
db_query($sql, $form['studiejaar']['#value'], $form['opleiding']['#value'], $form['soortStage']['#value'],
            $form['stageplaats']['#value'], $form['periodes']['#value']);


  • First, use $form_state['values']['studiejaar'] and so on instead of $form.

  • You probably shouldn't specific the id, instead, just leave that away and MySQL will automatically increment the value.

  • If you have defined your table with hook_schema() (what you need to do!), you could also use drupal_write_record().

0

精彩评论

暂无评论...
验证码 换一张
取 消