0

特定のフィールド値を持つノードを検索するフォームを作成しようとしています。以下は私のフォームです。ノードには都市フィールド、分類用語などが含まれています。知りたいのは、mysql select から取得した結果を新しい drupal ページに表示する方法だけです。

    function q_search_form($form_state) {
$form['qsearch']['category'] = array(
    '#type' => 'select',
    '#options' => array('' => 'Any', 2 => 'Automotive', 1 => 'Real Estate'),
    '#attributes' => array('class' => 'drop-box'),
    '#prefix' => '<table width="470"><tr><td width="170">Select Category</td><td width="300">',
    '#suffix' => '</td></tr>'
);
$form['qsearch']['city'] = array(
    '#type' => 'select',
    '#options' => array('' => 'Any', 'kozhikode' => 'Kozhikode', 'kochi' => 'Kochi'),
    '#attributes' => array('class' => 'drop-box'),
    '#prefix' => '<tr><td width="170">City</td><td width="300">',
    '#suffix' => '</td></tr>'
);
$form['qsearch']['property'] = array(
    '#type' => 'select',
    '#options' => array('' => 'Any', 18 => 'Land and House', 17 => 'Land'),
    '#attributes' => array('class' => 'drop-box'),
    '#prefix' => '<tr><td width="170">Property</td><td width="300">',
    '#suffix' => '</td></tr>'
);
$form['qsearch']['wanto'] = array(
    '#type' => 'select',
    '#options' => array('' => 'Any', 'sell' => 'Sell', 'buy' => 'Buy'),
    '#attributes' => array('class' => 'drop-box'),
    '#prefix' => '<tr><td width="170">Want to</td><td width="300">',
    '#suffix' => '</td></tr>'
);
$form['qsearch']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Search'),
    '#attributes' => array('id' => 'Search', 'class' => 'srch-button'),
    '#prefix' => '<tr><td><a class="adv-srch" href="#">Advance Search</a></td><td>',
    '#suffix' => '</td></tr></table>'
);
return $form;
}

 function q_search_form_submit($form, &$form_state) {
   $wantto = $form_state['values']['wanto'];
    $property = $form_state['values']['property'];
    $city = $form_state['values']['city'];
     $category = $form_state['values']['category'];
      $sql = ' SELECT A.nid FROM node A 
        LEFT JOIN content_type_item B ON A.vid = B.vid
        LEFT JOIN term_node C ON A.vid = C.vid
        LEFT JOIN term_hierarchy D ON D.tid = C.tid
        WHERE A.type = "item" 
        AND B.field_tr_type_value = "'.$wantto.'"
        AND B.field_city_value = "'.$city.'"
        AND D.parent = '.$category.'
        AND C.tid = '.$property.'
   ';
   $result = db_query($sql);   

   }
4

1 に答える 1