I am studying how to create a custom module in Drupal7, so far I have created a simple module that will accept subscribers by registering.
These are the fields I have for my database, and has finished the function that will accept user input.
Table: simple_subscribe
sid , firstname, lastname, email I then proceeded to create the function that will display all of the subscribers so far this is what I got
function subscription_view_form() { $result = db_query("SELECT * from subscribe"); $record = $result->fetchAll(); echo '<pre>'; print_r($record); echo '</pre>'; } I am using print_r($record); to display the information, but all it displays is the objects on top of the website, before the navigation
Array ( [0] => stdClass Object ( [sid] => 1 [firstname] => John [lastname] => Doe [email] => [email protected] ) [1] => stdClass Object ( [sid] => 2 [firstname] => Test [lastname] => Beta [email] => [email protected] ) ) edit
I am using the hook_menu() to display a form on /subscriptions but I can't output the subscribers inside the content area, I also wanted to list it in a table, I only did the print_r($records) to test if it is fetching the data. I wanted to know how to output it properly inside the content area not above it?
function subscription_menu() { $items[ 'subscriptions' ] = array( 'title' => 'View the Subscribers', 'description' => 'Subscription form available for subscribers', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'subscription_view_form' ), 'access arguments' => array( 'access content' ), 'file' => 'subscription.pages.inc' ); return $items;
subscription_view_form()is apage callbackin ahook_menu()item? if so, it is supposed to return information, not print it directly; otherwise, yes, this is exactly what will happen. or is it being called somehow or somewhere else. a lot more detail is going to be needed to help you out further.