hi how can i create a module

Category: Drupal 7

om-sai-ram
Asked:
2013-06-27 9:24 am EST

Hits: 1,252
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
(
ID INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(ID),

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,


);

$quiz['submit']=array(
'#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);
db_insert('quiz')
->fields(array(

'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'],

))
->execute();

$message = 'You have submitted a Question ' ;

drupal_set_message(t($message));

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

}

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

Best answer chosen by User

0

Scott
Staff
20,166 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
om-sai-ram
29 Points
2013-06-27 10:00 am EST
i am working on drupal 7
om-sai-ram
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
om-sai-ram
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.

https://drupal.org/forum

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

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

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: support@InMotionHosting.com
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!