Wednesday, February 22, 2012

some important mysql function

1.  count()

2. max();

3. in() ;

4. min();

5. avg();

6. sum();

7.  date()

8. date different ()

JOIN Operation In MYSQL


1. Select All row from Table Left (Table 1) even if there are no matches in the right table (table2).
2. select All Row from Right Table (Table2) who is match in left Table ;

SELECT * FROM Table1 LEFT JOIN Table2 ON Table1.colName=Table2.colName


1. Select All row from RIGHT Table (Table 2) even if there are no matches in the left table (table1).
2. select All Row from left Table (Table1) who is match in RIGHT Table ;

SELECT * FROM Table1 RIGHT JOIN Table2 ON Table1.colName=Table2.colName


1. Select All row from Both Table(Table1 , Table2)

SELECT * FROM Table1 FULL JOIN Table2 ON Table1.colName=Table2.colName

Tuesday, February 21, 2012

what is unique key in mysql

  1. unique  is key and its always unique,    that means no repeat  ,
  2. unique is just like primary key but unique  may be NULL and primary key is not NULL

how to create unique key in mysql table

CREATE TABLE  tablename
id  int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),

how to create unique key in mysql with multiple columns

create unique key with combination of multiple column

alter table tbName add unique index(column1column2column3,.....)

Sunday, February 19, 2012

how to show all post in wordpress but not first

how to show all post of WordPress but not first  and all post is in descending order

    <?php $p=1;  query_posts($query_string '&orderby=id&order=ASC'); ?>


     <?php if (have_posts()) : while (have_posts()) : the_post();?>

     <?php $p++ ;  if($p==2){ continue ; } ?> 

    <h2 class="section_headline"><?php the_title();?></h2>


<?php   //the_excerpt ();  ?>

<?php  the_content(); ?>  

how to show category id or page id in wordpress

how to show categori id in wordpress

how to show page id in WordPress 

<?php echo $cat_idget_query_var(‘cat’) ; ?>

<?php echo $page_idget_query_var(‘page_id’) ; ?>

Friday, February 17, 2012

show hide div using jquery , how to use show() , hide() function in jquery

Show Hide div using jquery click here for show div

show hide div jquery example 

function showdiv(){


function hidediv(){

<div id="mydiv" style="display:none; background-color:#FF66CC; width:300px ; height:40px" > <b> Hi , I am Rajeev Dhar Dwivedi </b> </div>

<input type="button" onclick="showdiv()" value="Show Div"  />
<input type="button" onclick="hidediv()" value="Hide Div"  />

how to use split() function in javascript

How to use Split() function in javascript String = Rajeev-Dhar-Dwivedi

function splitresult(){
var name = 'Rajeev-Dhar-Dwivedi' ;

var val=name.split("-");

<b> String = Rajeev-Dhar-Dwivedi </b>
<input type="button" onclick="splitresult()" value="Call Slipt Function"  />

for example you have a string Rajeev-Dhar-Dwived and you want to cut string every - seprator them use split() function in javascript split() function is just like to explote() function in PHP
structer :
var arrayval=string.split("seprator"); 
var str = 'Rajeev-Dhar-Dwivedi' ;
var val=name.split("-");
val[0]; // Rajeev
val[1]; // Dhar
val[2]; // Dwivedi

how to reload page using javascript

How to reload page using javascript

function reloadpage(){
window.location.reload() ;


<input type="button" onclick="reloadpage()" value="Reload page"  />

how to add and remove class using jquery

Add Remove Class using jquery Name :

function addcls(){

 $("#name").attr("class","classname1 classname2");  

function removeclass(){

Name :
<input type="text" name="name" id="name" value="my name" onclick="(this.value='')" /><br />

<input type="button" onclick="addcls()" value="Add Class"  />
<input type="button" onclick="removeclass()" value="Remove Class"  />

Tuesday, February 14, 2012

how to show menu in wordpress

<?php wp_nav_menu( array('menu' => '22' )); ?>  // 22 menu id

show one or more post in wordpress

show one or more WordPress post in header , index , or category page according to you

= array( 'numberposts' => 1'order'=> 'ASC''orderby' => 'id''category' => );
$postslist get_posts$args );
       foreach (
$postslist as $post) :  setup_postdata($post); ?>
      <?php the_content(); ?>
      <?php edit_post_link('Edit'); ?>
      <?php endforeach; ?>

numberposts = how many post , you want to show
order = ASC  or DESC
orderby = id , title , etc
category =  category id

Sunday, February 12, 2012

show wordpress post in descriding order

    <?php query_posts($query_string . '&orderby=id&order=ASC'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post();?>
    <div class="wrap_box">
    <h2 class="section_headline"><?php the_title();?></h2>
<?php  the_content(); // the_excerpt ();  ?>

<?php edit_post_link('Edit'); ?>
    <?php endwhile; endif; ?>

Some Important Wordpress Function

Some Important Wordpress Function 

<?php  the_content(); // get  content in wordpress ?>

<?php the_excerpt (); //get part of content in wordpress ?>

<?php the_title();  // get title of page and post  ?>

<?php edit_post_link('Edit');  // edit link when wp-admin login ?>

<?php bloginfo('home'); //http://localhost/myproject ?>

<?php bloginfo('template_url'); //http://localhost/myproject/wp-content/themes/mythem  ?>

<?php bloginfo('stylesheet_url'); //get style.css file from youe them ?>

<?php bloginfo('name');  // name of your site  ?>


How to Know user ( admin ) Login in wordpress site

     <?php if ( is_user_logged_in() ) {

   echo ' user is loin ' ;

} else {

 echo ' Not Login ' ;

} ?>

List of Post Category Wise in wordpress

for example show this type

Category 1
   post 2
category 2
   post 1
   post 2
Category 3
   post 2

 code :

<?php // get all the categories from the database 

 $cats get_categories();
// loop through the categries

 foreach ($cats as $cat) {
 // setup the cateogory ID 
 // Make a header for the cateogry 
 echo "<h2>".$cat->name."</h2>";
 // create a custom wordpress query
 // start the wordpress loop! if (have_posts()) : while (have_posts()) : the_post(); ?> 
<?php // create our link now that the post is setup ?> 

 <a href="<?php the_permalink();?>"><?php the_title(); ?></a> 

<?php echo '<hr/>'?> 

<?php endwhile; endif; 

 // done our wordpress loop. Will start again for each category ?> 

 <?php // done the foreach statement ?>  

Saturday, February 11, 2012

how to use wordpress

1. download WordPress from 

how to change string into date in mysql

how to change string into date in mysql

//how to change string into date in mysql 
str_to_date(string_data, format)

  Example : 
  select *,floor(datediff('".date("Y-m-d")."',str_to_date('dob','%d-%m-%Y'))/365) as agediff from tablename 
  dob = column name  and varchar type 

Different between two date in javascript

calculating difference between two dates in java script

function changedays(x){
    var one=1000*60*60*24  

Different Between Two Date in PHP

<?php  // different between two date in php 
function dateDiff($start$end) {   // create your function here 
$date1 strtotime($start);
$date2 strtotime($end);
$diff $date2 $date1;
round($diff 86400);


on click Enable and Disable check box on jquery

click   Show   Add   Edit   Delete  

code : 
<script src=""></script>
function EnableCheckBox(x){
var classname = $(x).attr("class");
 } else {

 <td> click &nbsp; </td>
 <td><input type="checkbox" name="subsection-click[]" value="show" class="click" onclick="EnableCheckBox(this);" /> Show &nbsp; </td>
  <td> <input type="checkbox" name="subsection-click[]" value="add" class="clickaction"  disabled="disabled" /> Add  &nbsp;  </td>
  <td> <input type="checkbox" name="subsection-click[]" value="edit" class="clickaction" disabled="disabled" /> Edit  &nbsp; </td>
  <td> <input type="checkbox" name="subsection-click[]" value="delete" class="clickaction" disabled="disabled" /> Delete   &nbsp; </td>

Friday, February 10, 2012

how to use .load() function

var url = "file.php";
$("#loaddata").load(url,{},function (responseText, textStatus, XMLHttpRequest) {


how to know checkbox is checked in jquery

how to know checkbox is checked in javascript, Here we are provide a example similar to that 

Select Check box

code for this example :

<script src=""></script>

function selectcheckbox(x){
var cls = $(x).attr('class');

alert('chek box is checked');
else { alert('check box is unchecked');}

<form action="" method="">
<input type="checkbox"  name="checkboxname" value="checkboxvalue" class="checkboxcls"  onclick="selectcheckbox(this)"/> Select Check box

Wednesday, February 8, 2012

how to use focus function javascript

 focu()  function  is use in javascript for focus of input box when you enter any wrong values in inputbox
for example email , mobile number .. etc

example :

when you enter wrong email them your cursor blink on input box

 code : in javascript  document.getElementById('email').focus();

in jquery    $('#email').focus() ;   where email s id of input box

Email Validation In javascript

email validation in javascript or mail validation in javascript here we are provide a demo of
email validation in javascript

code :

function emailvalidation(){ 
   var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; 
   email = document.getElementById('email').value ;
   alert('please Enter Valid Email Id');
    return false ;

 <form >
 <label> Email Id : </label>
 <input type="text" name="email" value="please enter email id " id="email" onclick="(this.value='')"  />
 <input type="submit" name="button" value="Chick Email" onclick="return emailvalidation()"  />

mobile number validation in javascript

mobile number validation is very important topic in javascript , we are try to say how to use mobile number validation in javascript , i think this is very useful for you thanks

function mobileNoValidation()
var mobile=parseInt(document.getElementById('mobile').value );

//var reg = /^([0-9]{10,10})$/;
var reg = /^\d{10}$/;

if(reg.test(mobile) == false) {

alert('Please Enter Valid mobile number');  document.getElementById('mobile').focus();
return false;
<form action='#'>
<input type="text" name="mobileNo" id="mobile" value="pease enter mobile no " maxlength="10" onClick="(this.value='')" onkeypress="return IsNumber(event , this);"  />

<input  type="submit" value="Submit"  onclick=" return  mobileNoValidation();" maxlength="12"  />