//Create Menu
function ajax_form_menu(){
$item['regislist'] = array(
'title' => 'List of regis User',
'access callback' => TRUE,
'page callback' => 'drupal_get_form',
'page arguments' => array('list_regis_user'),
'file' => 'ajax_form.inc',
);
return $item;
}
Create ajax_form.inc file in module folder.
<?php
function list_regis_user(){
$form = array();
$query = db_select('ajax_form', 'n');
$query ->fields('n', array('ajid', 'first_name', 'last_name', 'email', 'gender', 'number'));
//$query ->condition ('first_name', '','!=');
$result = $query->execute();
$form['requests'] = array(
'#prefix' => '<div id="interview-request">',
'#suffix' => '</div>',
'#tree' => TRUE,
'#theme' => 'table',
'#header' => array(t('Sr no.'), t('First name'), t('Last NAme'), t('Email'), t('Gender'), t('Number')),
'#rows' => array(),
);
while($record = $result->fetchAssoc()) {
if($record['first_name'])
{
$nid = array('#id' => 'id',
'#type' => 'markup',
'#markup' =>$record['ajid'],
);
$first = array('#id' => 'first',
'#type' => 'markup',
'#markup' => $record['first_name'] ,
);
$last = array('#id' => 'last',
'#type' => 'markup',
'#markup' => $record['last_name'],
);
$email = array('#id' => 'email',
'#type' => 'markup',
'#markup' => '<b>' . $record['email'] . '</b>',
);
$gender = array('#id' => 'gender',
'#type' => 'markup',
'#markup' => $record['gender'],
);
$number = array('#id' => 'number',
'#type' => 'markup',
'#markup' => $record['number'] ,
);
$form['requests'][] = array('nid' => &$ajid,
'first' => &$first,
'last' => &$last,
'email' => &$email,
'gender' => &$gender,
'number' => &$number,
);
$form['requests']['#rows'][] = array(array('data' => &$ajid),
array('data' => &$first),
array('data' => &$last),
array('data' => &$email),
array('data' => &$gender),
array('data' => &$number),
);
unset($ajid);
unset($first);
unset($last);
unset($email);
unset($gender);
unset($number);
}
}
return $form;
}
function ajax_form_menu(){
$item['regislist'] = array(
'title' => 'List of regis User',
'access callback' => TRUE,
'page callback' => 'drupal_get_form',
'page arguments' => array('list_regis_user'),
'file' => 'ajax_form.inc',
);
return $item;
}
Create ajax_form.inc file in module folder.
<?php
function list_regis_user(){
$form = array();
$query = db_select('ajax_form', 'n');
$query ->fields('n', array('ajid', 'first_name', 'last_name', 'email', 'gender', 'number'));
//$query ->condition ('first_name', '','!=');
$result = $query->execute();
$form['requests'] = array(
'#prefix' => '<div id="interview-request">',
'#suffix' => '</div>',
'#tree' => TRUE,
'#theme' => 'table',
'#header' => array(t('Sr no.'), t('First name'), t('Last NAme'), t('Email'), t('Gender'), t('Number')),
'#rows' => array(),
);
while($record = $result->fetchAssoc()) {
if($record['first_name'])
{
$nid = array('#id' => 'id',
'#type' => 'markup',
'#markup' =>$record['ajid'],
);
$first = array('#id' => 'first',
'#type' => 'markup',
'#markup' => $record['first_name'] ,
);
$last = array('#id' => 'last',
'#type' => 'markup',
'#markup' => $record['last_name'],
);
$email = array('#id' => 'email',
'#type' => 'markup',
'#markup' => '<b>' . $record['email'] . '</b>',
);
$gender = array('#id' => 'gender',
'#type' => 'markup',
'#markup' => $record['gender'],
);
$number = array('#id' => 'number',
'#type' => 'markup',
'#markup' => $record['number'] ,
);
$form['requests'][] = array('nid' => &$ajid,
'first' => &$first,
'last' => &$last,
'email' => &$email,
'gender' => &$gender,
'number' => &$number,
);
$form['requests']['#rows'][] = array(array('data' => &$ajid),
array('data' => &$first),
array('data' => &$last),
array('data' => &$email),
array('data' => &$gender),
array('data' => &$number),
);
unset($ajid);
unset($first);
unset($last);
unset($email);
unset($gender);
unset($number);
}
}
return $form;
}
No comments:
Post a Comment