InMotion Hosting Support Center

hi how can i create a module

Category: Drupal 7

2013-06-27 9:24 am EST

Hits: 1,273
i want to create a module who's value goes to database and also i can fetch that value from database

You must login before you can ask a follow up question.

You must login before you can submit an answer.

this is my code now i want to fetch those values

mysqli_query($con,"CREATE TABLE quiz

question VARCHAR(111),
op1 VARCHAR(111),
op2 VARCHAR(111),
op3 VARCHAR(111),
op4 VARCHAR(111),
ans VARCHAR(111)

function quiz_test_menu() {
$items['QUIZTEST'] = array(
'title' => 'QUIZ TEST',
'page callback' => 'drupal_get_form',
'page arguments' => array('quiz_test'),
'access callback' => TRUE,
return $items;

function quiz_test($quiz,&$quiz_submit) {

$quiz['question'] = array(
'#title' => t('enter the question'),
'#type' => 'textfield',

'#required' => TRUE,


$quiz['op1'] = array(
'#title' => t('option1'),
'#type' => 'textfield',
'#required' => TRUE,


$quiz['op2'] = array(
'#title' => t('op2'),
'#type' => 'textfield',
'#required' => TRUE,


$quiz['op3'] = array(
'#title' => t('option3'),
'#type' => 'textfield',

'#required' => TRUE,

$quiz['op4'] = array(
'#title' => t('option4'),
'#type' => 'textfield',
'#required' => TRUE,

$quiz['ans'] = array(
'#title' => t('correct ANS'),
'#type' => 'textfield',
'#required' => TRUE,


'#value' => 'Submit',
'#type' => 'submit',
'#submit' => array('quiz_test_submit'),

return $quiz;


function quiz_test_submit($quiz, &$quiz_values){
// watchdog('Form_test', 'quiz_test', array(), WATCHDOG_DEBUG);

'question' => $quiz_values['values']['question'],
'op1' => $quiz_values['values']['op1'],
'op2' => $quiz_values['values']['op2'],
'op3' => $quiz_values['values']['op3'],
'op4' => $quiz_values['values']['op4'],
'ans' => $quiz_values['values']['ans'],


$message = 'You have submitted a Question ' ;


$resource = mysqli_query("SELECT FROM quiz where id = ''" );
$count = mysqli_num_rows($resource);
$total = ' total records are entere '.$count;
// drupal_set_message(t($total));


29 Points
2013-06-27 10:36 am EST
hi any body knows the solution then tell solve the problem
29 Points
2013-06-28 05:03 am EST

Best answer chosen by User


43,761 Points
2013-06-27 9:51 am EST
Hello om-sai-ram,

Developing a module will require knowledge of coding. I do have a link below for the Drupal Module Developer guide. This will help you with beginning the process of developing your own custom module.

Module developer's guide

Best Regards,
Scott M

You must login before you can post a comment about this answer.

thanks sir for help but
i have created module whose value goes to data base but i cant be able to fetch that value from database so plese help me solve the problem
29 Points
2013-06-27 10:00 am EST
i am working on drupal 7
29 Points
2013-06-27 10:01 am EST
this is not help full link
i am asking u to send me code i am waiting
29 Points
2013-06-29 2:21 am EST
We checked into your Drupal issue and we were not able to find a solution to the issue. Please check the Drupal forums as we do not have any solution at this time. Sorry for this.

Best regards,
James R
5,889 Points
2013-07-01 11:57 am EST
Like this Question?

Forum Login

You are NOT logged in. You can still browse our Support Center.

To participate within our Community Support Forum:

Need more Help?

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!