이 코드는 SQL 쿼리를 작성하는 "드루팔 방법"을 따라야한다 "드루팔 준수"합니다.
당신은 (이 필요한 경우 드루팔이 접두사를 추가 할 수 있습니다)에 SQL 테이블의 이름 주위에 사용 {...} 할 필요가, 당신은에 어떤 양식, 그리고
$res = db_query("select field1 from {content_type_1}");
while ($row = db_fetch_array($res)) {
$rows[] =$row['field1'];
}
를 사용한다 사이트, 당신은 form API (select 문)를 사용한다
그래서 코드를해야 뭔가 같은 :
function mymodule_form(&$form_state) {
$form['mySelect'] = array(
'#type' => 'select',
'#title' => t('A title'),
'#default_value' => '',
'#options' => get_rows();
);
return $form
}
function get_rows() {
$res = db_query("select field1 from {content_type_1}");
while ($row = db_fetch_array($res)) {
$rows[] = $row['field1'];
}
return $rows;
}
/* .. more code if needed .. */
// Then you can print your form.
// This should be called by a hook_menu or a theme() function ... not alone like here.
echo drupal_get_form('mySelect');
파스칼 마틴 감사합니다. 그것은 drupal에서도 작동합니다. – user677900
위대한 :-) 다행스럽게 도울 수 있습니다. 재미있어! –