Saturday, January 15, 2011

find the current date using MySQL

SELECT now();
or
SELECT CURDATE();
or
SELECT CURRENT_DATE();

submit a form without submit button

document.formname.submit(); //It will work when we are using single form in a page

document.forms['formname'].submit(); //It will work when we are using multiple forms

// above formname is our formname

submit a form using javascript

document.formname.submit(); //It will work when we are using single form in a page

document.forms['formname'].submit(); //It will work when we are using multiple forms

// above formname is our formname

maximum length of a database name, table name, field name in MySQL

Database name: 64 characters
Table name: 64 characters
Column name: 64 characters

Wednesday, October 27, 2010

Simple wordpress widget

Take new php file then copy the below code to file and put the file in plugins folder and activate the plugin

Now you can see the widget in widgetarea of wordpress named 'My First Widget'

/* Plugin Name: Simple Widget */
function widget_myuniquewidget() {
echo "This is simple widget";
}
register_sidebar_widget('My First Widget','widget_myuniquewidget');

wordpress admin menu page

/* Plugin Name: Simple Admin Menu */

add_action('admin_menu', 'mt_add_pages');

function mt_add_pages() {
add_menu_page('Main Page','Main Page', 'manage_options', 'main-page-handle', 'main_page' );
add_submenu_page('main-page-handle','Sub Page1', 'Sub Page1', 'manage_options', 'sub-page1', 'sub_page1');
add_submenu_page('main-page-handle', 'Sub Page2', 'Sub Page2', 'manage_options', 'sub-page2', 'sub_page2');
}

function main_page() {
echo "Main Page";
}

function sub_page1() {
echo "Sub Page1";
}

function sub_page2() {
echo "Sub Page2";
}