Friday, July 29, 2011

Google Maps using Drupal

Adding a Google map to Drupal's contact form

1.Download and install the GMap module.

2.Go to your modules page and enable the "Contact" and "GMap" modules.

3.Request a Google Maps API key, enter it on your GMap page and click on the "Save configuration" button.

4.Go to your input formats page and select "Full HTML" as default input format. Configure the "Full HTML" input format, select "GMap filter" and click on the "Save configuration" button.

5.Use the online GMap macro builder to design your map and copy the generated macro text to the clipboard.

6.Go to your contact form settings page, paste the macro into the "Additional information" field and click on the "Save configuration" button.

7.Open the "template.php" file of your theme in your favorite editor and add the following function (also explained here):

function theme_contact_mail_page($form){
  $output = check_markup(variable_get('contact_form_information',
    t('You can leave a message using the contact form below.'))); 
  $output .= drupal_render($form);
  return $output;

8.That's it! Visit your contact page to verify that the Google map is displayed correctly.

Tuesday, July 26, 2011

What's New in Drupal 7

  1. New Minimum System Requirements:

This is not a complete list of requirements. Please read the complete list of requirements.
  • Database: MySQL 5.0.15 or PostgreSQL 8.3
  • PHP Version 5.2 or higher
  • PHP Memory: 40M - 64M

 2. Security:

  • More secure implementation for scheduled tasks (cron.php).
  • More secure password system.
  • More secure log-in system.
  • Modules can be updated via the web.

 3. Usability:

  • Administrative links to edit existing page elements are now available on each web page, without having to go to an administration page first.
  • Improved support for integration of WYSIWYG editors.
  • Added more drag-and-drop for administrative tasks.
  • Permissions now have the ability to handle more meta-data (permissions now have a description).
  • User 1 created as part of the installation process.
  • Added features to the default install profile (tagging on the Article content type).
  • Setting up automated task runs (cron) can now be achieved via Drupal's configuration alone, without having to install any scripts on the web server.
  • Redesigned password strength validator to make it kinder and gentler, and clearer.
  • Renamed "input formats" to "text formats".
  • Added support for default text formats to be assigned on a per-role basis.
  • Moved text format permissions to the main permissions page
  • Added "vertical tabs", a reusable interface component that features automatic summaries and increases usability.
  • Improved time zone support
  • Removed per-user themes: Contributed modules with similar functionality are available.
  • Added new "Shortcuts" module to allow user to create their own menu for the pages they visit the most.

  4. Database:

  • Added query builders for INSERT, UPDATE, DELETE, MERGE, and SELECT queries.
  • Support for master/slave replication, transactions, multi-insert queries,delayed inserts, and other features.
  • Added support for the SQLite database engine.
  • Default to InnoDB engine, rather than MyISAM, on MySQL when available for greater scalability and data integrity.

  5. Several Performance Improvements Implemented

  6. Documentation:

  • Hook API documentation now included in Drupal core.

  7. News aggregator:

  • Added OPML import functionality for RSS feeds.
  • Added feed update options.

  8. Search:

  • Added support for language-aware searches.

  9. Testing:

  • Added test framework and tests.

 10. Theme system:

  • Removed the Bluemarine, Chameleon and Pushbutton themes. These themes live on as contributed themes
  • Added "Bartik" theme as the default user interface theme.
  • Added "Seven" theme as the default administration interface theme.
  • Added "Stark" theme to make analyzing Drupal's default HTML and CSS easier.

 11. File handling:

  • Files are now first class Drupal objects with file_load(), file_save(),
    and file_validate() functions and corresponding hooks.
  • Files use PHP stream wrappers to enable support for both public and private files and to support pluggable storage mechanisms and access to remote resources (e.g. S3 storage or Flickr photos).
  • Added a field specifically for uploading files, previously provided by
    the contributed module FileField.

 12. Image handling:

  • Improved image handling, including better support for add-on image
  • Added a field specifically for uploading images, previously provided by the contributed module ImageField.

 13. Better Support for Multisite Installations

 14. Added RDF support

 15. Better support for search engine optimization and web linking

 16. Added ability to add custom fields

  • Provides most of the features of the former Content Construction Kit (CCK) module.
  • Custom data fields may be attached to nodes, users, comments and taxonomy terms.
  • Node bodies and teasers are now fields instead of being a hard-coded property of node objects.
  • Fields are translatable.

 17. Installer can be run from the command line

 18. JavaScript changes

  • Upgraded the core JavaScript library to jQuery version 1.4.2.
  • Upgraded the jQuery Forms library to 2.36.
  • Added jQuery UI 1.8, which allows improvements to Drupal's user experience.

 19. Improved node access control system

 20. Task handling

  • Improved handling of long-running tasks.

Using Views 2 in Drupal 6 to Create a Related Pages Block

The first step in your new Views journey is to Add a new view at admin/build/views. Just click on the tab near the top of the screen:

add a view

Now you'll be asked to name your view something computer-friendly - in this case you'll name it related_by_term:

Name your view

Once you click through, you'll be presented with the granddaddy of all administration screens, but don't be afraid, things move pretty quickly in here if you know what you're doing. Notice the Orange text in the top right: New view. Until you push the Save button at the bottom of the screen, all you hard work could be lost, and especially don't forget to save once you've finished configuring your view.

Main views screen

I want you to skip all those fancy options and dive right in: you've got to eat your vegetables, so let's get the hard part over with and set up the arguments:

Add an argument

Arguments were the most powerful (and hardest to understand) feature of the old Views - think of this as the WHERE clause of your SQL statement. Your first and only argument will be keyed off of a Taxonomy Term ID:

taxonomy argument type

Since you don't have Panels at your disposal, you'll need to specify a Default Argument. There are several (powerful) ways to accomplish this, but in your case, resort to tried-and-true PHP Code. The code displayed here loads the object for the current $node (if any) and concatenates a list of all the Term IDs on that node, then returns the string to Views in the format 1+2+3, just like the arguments on taxonomy/term pages:

use PHP to specify the default argument

In order to activate this muitliple-term-driven argument scheme, you need to check a few boxes below the PHP code. The first sets up the fact that you can use the 1+2+3 format, and the second removes duplicate entries that have more than one term. Make sure you read the warnings about performance; if you don't use multiple taxonomy terms, leave this box unchecked. You can proceed by clicking the Update button:

Allow multiple terms, reduce duplicates

At this point, you'll see an error message inviting you to extract some fields in your view, which is set up to display fields by default. If you wanted to view full nodes or teasers, you could change that option and be safe, but the block you want to build needs titles that link to the node:

egads, an error message

Now you want to tackle adding fields to your view. This is the building block of any view, analogous to the SELECT part of a SQL statement:

Add a field

You should recognize this next picture, because it's very similar to the way you chose your argument type, and how you'll choose your filter in the future. Use the Add button to move to the next screen:

you want to see the node title

If you don't delete the word "Title" in the Label text box, it will appear next to all your links. There are some situations where this is wanted; yours is not one of them. You also said you wanted the titles to be links, so
check that box:remove the Label and enable links

At this stage, you should be able to get a working preview of your view. Just type a number or a 1+2 in the arguments area and push the button to trigger the AJAX. That blue text is your view, and there's also some geeky information below. Notice that currently "This display has no path"; that's OK, you want a block:

use some arguments to get a live preview

At this point, you still haven't told Views that you want your view to be a block, so make sure you choose block from the drop-down in the main interface. If you're working strictly with Page nodes, you may also want to throw a filter on your view to limit the results. You also should never forget the all-important Save
button:filter and save your view

The last thing you need to view is activate your block on admin/build/block (you may need to use block visibility rules, but that's another tutorial), and finally visit one of your Taxonomy-tagged pages to see if your other taxonomy-tagged pages shows up. If you've followed all the steps here, everything should be a snap. Maybe the best feature about your new block is the handy links that pop up when you mouse over your new block (if you have administer views access, at least):

your finished block with edit links

Well Dale, I think that should just about answer your question. Since this is my first Drupal 6 tutorial, I'll have to say, this was a lot more fun for me than I'm sure the last few days have been for you. Wave hello to Corey and Sterling and Derek and Daniel and the other NFi folks, and I hope I was able to save you some precious time with this post.

Monday, July 25, 2011

Drupal Vs Joomla Vs Wordpress



  • Very clean core code.
  • Good project leadership from Acquia.
  • Some very good developers available for hire.
  • Fewer clowns available for hire (you can either code Drupal or you can't, it's harder to fake it).
  • Can be made very server efficient in the right hands (scaleable).


  • Less ready made drop-in plugins. You're going to  have to get your hands dirty almost every time.
  • More imposing default user interface.
  • Fewer developers.
  • More expensive developers.



  • Good menu system.
  • Strong static page structure (cf. weblog).
  • Built-in membership/community features.
  • Long time on the market.
  • I'm searching here.


  • Built-in performance pretty sluggish/clunky.
  • Horrid built-in URLs.
  • Weak weblog section.
  • Hard to theme. A Mambo/Joomla site looks like Mambo/Joomla, like it or not.
  • Crappy built-in SEO. Leading SEO plugin belongs to a very peculiar developer and is encrypted (have fun repairing the SEO plugin, we reverse engineered and decrypted it for our site to make our changes even after paying for it).
  • Nasty, nasty core code. Very difficult to fix broken items.
  • Fractured community (never healed after Joomla/Mambo split back in 2006).
  • Most good plugins are pay.
  • Rather mediocre developers. Anyone who likes to code in Joomla/Mambo in 2011 ought to see a psychiatrist.
  • Developer pricing is all over the map as there are many old-school Mambo/Joomla developers still ought there churning out convoluted future-resistant code quite affordably.



  • Huge community.
  • Easy to optimise for performance thanks to Donncha O Caoimh and Frederick Townes. Great work guys.
  • Easy to theme in a unique way. A WordPress site does not have to look like a WordPress site.
  • Great plugin architecture.
  • Plugins for everything.
  • Lots of great professional developers.
  • Fast development cycle. Improvements every year.
  • Active leadership from Automattic and founding team. Particular thanks to Mark Jaquith for keeping the community running with less nepotism and more fairness than most collective human endeavour.


  • Fairly weak core code (in comparison to Drupal, but not Joomla!) but core getting better every year.
  • Lots of really crap faker developers in the pool who couldn't build a working website to save their mother's life.
  • Lots of popular but seriously broken plugins which will cripple your website performance forever and make it nearly impossible for you to cleanly upgrade (NextGen Gallery, I'm looking at you but not just you).
  • Really crappy commercial themes which are heavily marketed but compromise your ability to either upgrade or switch themes and compromise performance for the life of your site.
  • Weak static page management without adding plugins. Easily fixed with said plugins.
  • Too fast an upgrade cycle. You have to keep upgrading your site, whether you like it or not, for security reasons. There are no security releases only new versions. Feel the pain for a commercial site with running a full complement of plugins. Corollary: choose your plugins and plugin developers very, very carefully for cleanliness of code and frequency of update.


For a very large commercial project, I can see a justification for choosing Drupal. On a big project, most of your expense will be custom development anyway - everything has to be optimised and integrated - so you don't much care one way or another about a myriad of plugins which you will probably not use. I still wouldn't make that trade-off: slightly better core code for a vast pool of community contributed code. But it's a defensible position.

Joomla/Mambo should die a violent death. We did our first CMS project in Mambo and last year redeveloped a couple of existing sites in Joomla. Our best developers - very platform agnostic - threatened to quit if I accepted anymore Joomla work. Such crappy, convoluted spaghetti code they'd never seen. And these developers have had ample chance to see the worst side of WordPress.

The only justification for a site in Joomla/Mambo is that it's legacy (i.e. you already did a lot of custom development on it six years ago and don't have the budget to migrate) or that you are part of an international network standardised on Joomla/Mambo and the mothership discourages anyone from leaving the central platform (our client's situation). For everyone else, just migrate out and count your blessing that you got your site out alive. Enjoy the fresh air and clean code of WordPress (or Drupal).

WordPress is the platform of choice in my opinion for the small, medium or large business. Whatever holes you can find in WordPress (editorial management process, page management, ecommerce, membership site) are easily solved with high quality plugins.

The cool part about WordPress is that the core is kept clean so that you aren't forced to load code you don't need if you want a simple weblog. Thus WordPress can be a weblog, a corporate information site, a membership site, a store or an international news network.

We regularly develop advanced real estate sites in WordPress, maintain a very sophisticated insurance site, have developed elaborate furniture rental systems and develop the most delicious cooking sites as well as gorgeous online literary reviews. Not to mention political, news and law sites. All in WordPress.

The danger with WordPress include the overhyped commercial themes which don't solve your problems but pretend to (I'm looking at you and Thesis, WooThemes and ElegantThemes). A related danger are the weak developers and hangers on who have infested the huge WordPress community and enthusiastically give bad advice, whether about SEO or gallery plugins. These clowns will happily break your website for pay or into a defective by design commercial theme. Forewarned is forearmed.

Just like any other serious professional endeavour you need steady hands on deck when you want to take your site to the next level if you want to maintain performance, appearance and compatibility. Once you have substantial traffic or need ecommerce, WordPress is no longer a DIY venture for the non-programmer.

We personally recommend people start a new site on unless they are developing for an established business. Once you have an audience or a functioning business, self-hosted WordPress is the way to go. Even the sky is not a limit. There are few sites we could not develop better and faster in WordPress.

Monday, July 18, 2011

Advantage, Disadvantages Of PHP

::Main Advantages of PHP::

Let us see some of the important advantages of PHP. There are a lot of advantages of PHP. When it is compared with other scripting languages, some of the important highlights are as follows.

PHP is considered to be the fastest, as stated previously, when compared with other programming languages. You can really feel the speed when you are going to, implement live over the web.

Normally when you try to connect a database and fetch certain data, it usually takes time to connect the database, execute the statement, and get the data across. When these operations are performed by PHP it is really faster when compared with other types of scripting languages. Not only for the speed when connecting the database but also while using over other important applications.

Because of its high performance of speed, PHP is being used for some of the important administrations like the server administration over the web, mail functionalities.

Open Source
PHP is open source, open source is one where the user is given a free license to remodel or recode PHP, according to their wish. You might wonder if you can I do these things without source code. Yes would be the answer. Source code is shipped with PHP. It is open source remember.

Multi Platform
PHP supports various platforms, which mean PHP can be installed on almost every operating system, like the window-x, Linux, etc. You may choose the appropriate version and follow the instructions accordingly given in the Manual.PHP can be used on all major operating systems, including Linux, many Unix variants (including HP-UX, Solaris and OpenBSD), Microsoft Windows, Mac OS X, RISC OS, and probably others. PHP has also support for most of the web servers today. This includes Apache, Microsoft Internet Information Server, Personal Web Server, Netscape and iPlanet servers, Oreilly Website Pro server, Caudium, Xitami, OmniHTTPd, and many others. For the majority of the servers PHP has a module, for the others supporting the CGI standard, PHP can work as a CGI processor.

Databases Support
One of the most Sexiest feature of PHP is that it can plugin with most of the databases. It support with Adabas D, dBase, Empress, FilePro (read-only), Hyperwave, IBM DB2, Informix, Ingres, InterBase,  rontBase, mSQL, Direct MS-SQL, MySQL, ODBC, Oracle (OCI7 and OCI8), Ovrimos, PostgreSQL, SQLite, Solid Sybase, Velocis and Unix dbm

Easy Syntax
PHP syntax is quite easy to code, all the syntax are similar to the C language syntax, If you are very new to the programming environment then it will be a bit difficult task for you to code the PHP.

PHP also has support services using protocols such as LDAP, IMAP, SNMP, NNTP, POP3, HTTP, COM (on Windows)

::Main disadvantages of PHP::
Every language or scripting language has its own advantages or the disadvantages. Likewise, PHP has some of its own disadvantages.

But these disadvantages can be overcome using advantage methods.

Some people say it is a direct disadvantage, while some people say an indirect disadvantage.

Disadvantage indirectly means some of the aspects and functionalities in PHP, which are not being able to complete using the direct functionality. This particular disadvantage can be overcome using an advantage method.

Let us take a simple example, say redirection. Writing a piece of code from the client side or the server side - in some of the scripting languages there is a single task to achieve this - a single function will do so. But in the case of PHP it is done indirectly.

One more disadvantage is the Error Handling. It is believed that PHP has very poor handling errors qualities. Even this disadvantage can be over come using a feasible advantage solution.

Introduction to PHP 6

New PHP V6 features:
PHP V6 is currently available as a developer snapshot, so you can download and try out many of the features and changes listed in this article.

Improved Unicode support:
Much improved for PHP V6 is support for Unicode strings in many of the core functions. This new feature has a big impact because it will allow PHP to support a broader set of characters for international support. So, if you're a developer or architect using a different language, such as the Java™ programming language, because it has better internationalization (i18n) support than PHP, it'll be time to take another look at PHP when the support improves.
Because you can download and use a developer's version of PHP V6 today, you will see some functions already supporting Unicode strings.

What is Unicode? 

Unicode is an industry-standard set of characters, character encoding, and encoding methodologies primarily aimed at enabling i18n and localization (i10n). The Unicode Transformation Format (UTF) specifies a way to encode characters for Unicode.

Namespaces are a way of avoiding name collisions between functions and classes without using prefixes in naming conventions that make the names of your methods and classes unreadable. So by using namespaces, you can have class names that someone else might use, but now you don't have to worry about running into any problems. Listing 1 provides an example of a namespace in PHP.
You won't have to update or change anything in your code because any PHP code you write that doesn't include namespaces will run just fine. Because the namespaces feature appears to be back-ported to V5.3 of PHP, when it becomes available, you can start to introduce namespaces into your own PHP applications.

Depending on how you use PHP and what your scripts look like now, the language and syntax differences in PHP V6 may or may not affect you as much as the next features, which are those that directly allow you to introduce Web 2.0 features into your PHP application.

SOAP is one of the protocols that Web services "speak" and is supported in quite a few other languages, such as the Java programming language and Microsoft® .NET. Although there are other ways to consume and expose Web services, such as Representational State Transfer (REST), SOAP remains a common way of allowing different platforms to have interoperability. In addition to SOAP modules in the PHP Extension and Application Repository (PEAR) library, a SOAP extension to PHP was introduced in V5. This extension wasn't enabled by default, so you have to enable the extension or hope your ISP did. In addition, PEAR packages are available that allow you to build SOAP clients and servers, such as the SOAP package.
Unless you change the default, the SOAP extension will be enabled for you in V6. These extensions provide an easy way to implement SOAP clients and SOAP servers, allowing you to build PHP applications that consume and provide Web services.
If SOAP extensions are on by default, that means you won't have to configure them in PHP. If you develop PHP applications and publish them to an ISP, you may need to check with your ISP to verify that SOAP extensions will be enabled for you when they upgrade.

As of PHP V5.1, XMLReader and XMLWriter have been part of the core of PHP, which makes it easier for you to work with XML in your PHP applications. Like the SOAP extensions, this can be good news if you use SOAP or XML because PHP V6 will be a better fit for you than V4 out of the box.
The XMLWriter and XMLReader are stream-based object-oriented classes that allow you to read and write XML without having to worry about the XML details.

In addition to having new features, PHP V6 will not have some other functions and features that have been in previous versions. Most of these things, such as register_globals and safe_mode, are widely considered "broken" in current PHP, as they may expose security risks. In an effort to clean up PHP, the functions and features listed in the next section will be removed, or deprecated, from PHP. Opponents of this removal will most likely cite issues with existing scripts breaking after ISPs or enterprises upgrade to PHP V6, but proponents of this cleanup effort will be happy that the PHP team is sewing up some holes and providing a cleaner, safer implementation.
Features that will be removed from the PHP version include:
  • magic_quotes
  • register_globals
  • register_long_arrays
  • safe_mode

Using magic_quotes (discouraged):
// Assuming magic_quotes is on...

After preparing your PHP code for the new versions of PHP, your code should look like this,

Using parameterized queries (recommended)
// Using the proper parameterized query method for MySQL, as an example
$statement = $dbh->prepare("INSERT INTO USERS (USERNAME) VALUES ?");
 Using register_globals (discouraged):
// A security hole, because if register_globals is on, the value for 
// can be set by a user sending them on the query string 
// (i.e.,

if ($user_authorized) {
    // Show them everyone's sensitive data...
 Being specific instead (recommended):
function is_authorized() {
    if (isset($_SESSION['user'])) {
        return true;
    } else {
        return false;

$user_authorized = is_authorized();
Using deprecated registered arrays (discouraged):
    // Echo's the name of the user value given on the query string, like
    echo "Welcome, $HTTP_GET_VARS['username']!";

Using $_GET (recommended):
    // Using the supported $_GET array instead.
    echo "Welcome, $_GET['username']!";
The safe_mode configuration key, when turned on, ensures that the owner of a file being operated on matches the owner of the script that is executing. It was originally a way to attempt to handle security when operating in a shared server environment, like many ISPs would have. Your PHP code will be unaffected by this change, but it's good to be aware of it in case you're setting up PHP in the future or counting on safe_mode in your scripts. 

::Use this link for your reference::

New features of PHP 5.3

PHP 5.3.0 offers a wide range of new features:
  • Support for namespaces has been added.
  • Support for Late Static Bindings has been added.
  • Support for jump labels (limited goto) has been added.
  • Support for native Closures (Lambda/Anonymous functions) has been added.
  • There are two new magic methods, __callStatic and __invoke.
  • Nowdoc syntax is now supported, similar to Heredoc syntax, but with single quotes.
  • It is now possible to use Heredocs to initialize static variables and class properties/constants.
  • Heredocs may now be declared using double quotes, complementing the Nowdoc syntax.
  • Constants can now be declared outside a class using the const keyword.
  • The ternary operator now has a shorthand form: ?:.
  • The HTTP stream wrapper now considers all status codes from 200 to 399 to be successful.
  • Dynamic access to static methods is now possible.
  • Exceptions can now be nested.
  • A garbage collector for circular references has been added, and is enabled by default.
  • The mail() function now supports logging of sent email. (Note: This only applies to email sent through this function.)

Php getdate()

The getdate() function returns an array that contains date and time information for a Unix timestamp.
Key Description Example returned values
"seconds" Numeric representation of seconds 0 to 59
"minutes" Numeric representation of minutes 0 to 59
"hours" Numeric representation of hours 0 to 23
"mday" Numeric representation of the day of the month 1 to 31
"wday" Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday)
"mon" Numeric representation of a month 1 through 12
"year" A full numeric representation of a year, 4 digits Examples: 1999 or 2003
"yday" Numeric representation of the day of the year 0 through 365
"weekday" A full textual representation of the day of the week Sunday through Saturday
"month" A full textual representation of a month, such as January or March January through December
0 Seconds since the Unix Epoch, similar to the values returned by time() and used by date(). System Dependent, typically -2147483648 through 2147483647.

 $today getdate(); 

    [seconds] => 40
    [minutes] => 58
    [hours]   => 21
    [mday]    => 17
    [wday]    => 2
    [mon]     => 6
    [year]    => 2003
    [yday]    => 167
    [weekday] => Tuesday
    [month]   => June
    [0]       => 1055901520

Thursday, July 14, 2011

Theme Function:Template File Callback

Parent :
$items['sample'] = array(
        'title' => t('Admin'),
        'page callback' => 'drupal_get_form',
        'page arguments' => array('sample_link'),
        'access arguments' => array('access content'),
        'type' => MENU_LOCAL_TASK,
        'weight' => -9,
        'file' => ''
$items[sample/sample_form'] = array(
        'title' => t('Sample Form'),
        'page callback' => 'drupal_get_form',
        'page arguments' => array('sample_form'),
        'access arguments' => array('access content'),
        'type' => MENU_LOCAL_TASK,
           'weight' => -8,
        'file' => ''

 Normal Form Function Callback:
 function sample_form($form_state, $loop_count) {
  $form =array();
   $form['table_category'] = array(
    '#type' => 'select',
    '#options' => array(  
          'project_type' => t('Project Type'),
        'project_sub_type' => t('Project Sub Type'),
        'engagement_type' => t('Engagement Type'),
        'currency' => t('Currency'),
        'role' => t('Role'),
        'location' => t('Location'),
        'skill' => t('Skill'),
  $form['value'] = array(
    '#type' => 'textfield',
      '#size' => '15',
  $form['description'] = array(
    '#type' => 'textfield',
      '#size' => '15',
    return $form;

Theme Callback from module file for particular form:
function sample_theme($form){

    $themes = array(
            'sample_form' => array(
                  'render element' => 'form',
                    'template' => 'sample_form_file'),

//'sample_form' is a particular form that we are goin to theme using a separate tpl file
// 'sample_form_file' is the tpl file we are calling.i.e sample_form_file.tpl.php(tpl file)

sample_form_file(TPL File):

//echo '<pre>';print_r($form);
<div title="sample_form">
    <div align="center"><p><h1>Sample Form</h1></p></div>
    <div align="right" style="width: 100%; clear: both; padding-top:10px;">
        <div style="width: 04%; float: left;">
        <div style="width: 13%; float: left;padding-top:5px;">
        <?php print drupal_render($form['category']); ?>

Primary and Secondary Links In Tabs

Menu Hook:
function sample_menu() {
           $items = array();
           $items['sample'] = array(
           'page callback' => 'drupal_get_form',
           'page arguments' => array('sample_link'),
          'access arguments' => array('access content'),
           'type' => MENU_NORMAL_ITEM,
    $items['sample/home'] = array(
        'title' => t('Home'),
        'type' => MENU_DEFAULT_LOCAL_TASK,
        'weight' => -10,
        'access arguments' => array('access content'),
//MENU_LOCAL_TASK, will give the links as Tabs.

   $items['sample/home] = array(
        'title' => 'One',
           'page callback' => 'drupal_get_form',
        'page arguments' => array('one_link'),
        'access arguments' => array('access content'),
        'type' => MENU_LOCAL_TASK,
         'weight' => -9
   $items['sample/home/two'] = array(
        'title' => 'Two',
           'description' => 'Two',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('two_form'),
        'access arguments' => array('access content'),
        'type' => MENU_LOCAL_TASK,
        'weight' => -8
    $items['sample/home/three'] = array(
        'title' => 'Three',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('three_form'),
        'access arguments' => array('access content'),
        'type' => MENU_LOCAL_TASK,
        'weight' => -7
  return $items;

 * Primary Link Callback Functions

function sample_link(){
    drupal_set_title("Sample Page");

function one_link(){
    drupal_set_title("One Page");

 * Secondary Links Callback Functions

function two_form(){

    $form['category'] = array(
    '#type' => 'select',
    '#title1' => t('Category'),
    '#options' => array(
        'project_type' => t('Project Type'),
        'project_sub_type' => t('Project Sub Type'),
        'engagement_type' => t('Engagement Type'),
        'currency' => t('Currency'),
        'role' => t('Role'),
        'location' => t('Location'),
        'skill' => t('Skill'),

      $form['search'] = array(
      '#type' => 'submit',
      '#value' => t('Search'),

return $form;

function three_form() {
    $form['emp_id'] = array(
    '#type' => 'textfield',
    '#title' => t('Employee ID'),
    $form['emp_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Employee Name'),
return $form;

Simple Drupal Form Creation in Drupal 6

Module Hook:
function company_module_menu(){
    // Parent
    $items['company_module'] = array (
    'title' => t('Company Details'),
    'description' => t('Company Information '),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('company_module_form'),
    'access callback' => TRUE ,
    'type' => MENU_NORMAL_ITEM,
    // Child
    $items['company_module/list'] = array (
    'title' => t('List of Employees'),
    'description' => t('List of Employees  Information in Company'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('company_emp_list'),
    'access callback' => TRUE ,
    'type' => MENU_NORMAL_ITEM,
    return $items;
Parent :
Function Form Callback:
function company_module_form(){

    $form['company'] = array (
      '#type' => 'item',
      '#title' => t('Managing company details'),

    $form['company'] = array (
      '#type' => 'fieldset',
      '#title' => t('Company Details'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    $form['company']['name'] = array (
      '#type' => 'textfield',
      '#title' => t('Company Name  '),
      '#required' => TRUE ,
      '#default_value' => "",
      '#size' => 50,
      '#maxlength' => 45,

    $form['company']['addr'] = array (
      '#type' => 'textarea',
      '#title' => t('Company Address '),
      '#required' => TRUE ,
      '#default_value' => "",
      '#size' => 200,
      '#maxlength' => 200,
    $form['company']['typeofcompany'] = array (
      '#type' => 'select',
      '#title' => t('Type of Company  '),
      '#required' => TRUE ,
      '#default_value' => "",
    $form['company']['district'] = array (
      '#type' => 'select',
      '#title' => t('District Name  '),
      '#default_value' => "Pune",
    $form['company']['shift'] = array (
      '#type' => 'radios',
      '#title' => t('Shift'),
      '#options' => array(t('Yes'),t('No')),
   $form['company']['submit'] = array (
      '#type' => 'submit',
      '#value' => 'Submit',
    return $form;

Form Submit:

function company_module_form_submit($form_id,$form_state)
    $st = "";

    if ($form_state['values']['shift'] == '0')
        $st= "Yes";
        $st= "No";
     db_query("INSERT INTO tbl_company (name,addr,typeofcompany,district,shift)
                VALUES ('%s', '%s', '%s','%s', '%s')",
    drupal_set_message("Employee Detail Entered Successfully");
Child Callback:List of Employees:
Table Theming:
function company_emp_list(){
    $header = array(array('data'=>'Name','field'=>'name','style'=>'width:30%','sort'=>'desc'),
                    array('data'=>'Type Of Company','field'=>'typeofcompany','style'=>'width:15%'),
    $list_query = db_query("SELECT * FROM {tbl_company}".tablesort_sql($header));
    while($list_data = db_fetch_object($list_query)){
        $rows[] = array(array('data'=>$list_data->name),
    $output .= theme(table,$header,$rows);
    $form['output'] = array('#value'=>$output);
    return $form;

Difference Between Drupal 6 and Drupal 7 Table creation with Sorting and Pagination

Drupal 6 : Table creation with Sorting and Pagination
$header = array(array('data'=>'Name','field'=>'name','style'=>'width:20%','sort'=>'desc'),
                        array('data'=>'Type Of Company','field'=>'typeofcompany','style'=>'width:10%'),
//$header is header for the table and (Name,Address are column name)(name,addr are table column names) //width is used to allocate the table column width for each column

    $list_query = db_query("SELECT * FROM tbl_company".tablesort_sql($header)); 
//tbl_company is a table name and tblsort_sql for sorting the headers

    while($list_data = db_fetch_object($list_query)){
        $rows[] = array(array('data'=>$list_data->name),
//We may have one or more values in table,so we can use while loop to fetch all the rows

    $output .= theme(table,$header,$rows);
//theme(table,$header,$rows) is also written as table_theme($header,$rows)

    $form['output'] = array('#value'=>$output);
//We will assign the output as form value

    return $form;

For Pagination:
    $list_query = db_query("SELECT * FROM tbl_company".tablesort_sql($header));
    $count_query = "SELECT COUNT(*) FROM (" . $list_query . ") ";
    $limit = 25;
    $list_query_val = pager_query($query , $limit, 0, $count_query);

then we need to add the pager theme with the output as,

    $output .= theme(table,$header,$rows);
    $output .= theme('pager', NULL, $limit, 0);
//here our pager theme also rendered with the $output
    $form['output'] = array('#value'=>$output);

Drupal 7 : Table creation with Sorting and Pagination

$header = array(
 array('data' => 'Title', 'field' => 'title', 'sort' => 'asc'),
 array('data' => 'Node ID', 'field' => 'nid'),
 array('data' => 'Type', 'field' => 'type'),
 array('data' => 'Created', 'field' => 'created'),
 array('data' => 'Published'),
Sql Query: 
$query = db_select('node', 'n')
 ->condition('status', 1) //Only published nodes,
                          //change condition as it suits you
 ->extend('PagerDefault') //Pager Extender
 ->limit(10)             //10 results per page
 ->extend('TableSort')   //Sorting Extender
 ->orderByHeader($header) //Field to sort on is picked from $header
 ->fields ('n', array (
Execute the Query: 
$results = $query->execute(); 
$rows = array(); 
foreach ($results as $node) {
 $rows[] = array('data' => array(
      l($node->title, 'node/'. $node->nid .'/edit'),
Table Theme:
$html = theme('table', 
array('header' => $header,
       'caption' => 'Creating Drupal 7 style tables', 
//Optional Caption for the table
       'sticky' => TRUE, 
 //Optional to indicate whether the table headers should be sticky
       'empty' => 'No nodes created...', 
//Optional empty text for the table if resultset is empty
$html .= theme('pager',array(
   'tags' => array()
Some minor changes from drupal 6.
Other than that its same like drupal 6 table theming.
Thats it....