Thursday, December 20, 2012

updating two tables in a single query in mysql

updating two tables in a single query in mysql



UPDATE  tb1 , tb2  SET  tb1.name= 'new name', tb2.name = 'tb2 name'   WHERE   tb1.id = '1'  AND  tb2.id = '5'



delete data from two tables at the same time in mysql


delete record from two table in same time in mysql 

it is useful when we create two related table in mysql   

 // with inner join 

DELETE tb1, tb2 FROM tb1 inner JOIN tb2  WHERE tb1.id=tb2.tb1id and tb1.id=1



 // with left or Right Join 

DELETE tb1, tb2 FROM tb1 LEFT JOIN tb2 ON tb1.id=tb2.tb1id  WHERE tb1.id=1

Saturday, December 1, 2012

php call function within same class

<?php 
class a
public function f1(){
echo 
'this is a:f1 function';  
}
 
 function 
f3(){
 
a::f1(); // call here same class method
 echo 
'<br>Call here f1 function ';
 }
}

class 
b{

function 
f2(){ 

a::f3();
echo 
'<br> This is b:f2 function';
}

}
$ob= new b(); 

$ob->f2();

?> OutPut:
this is a:f1 function
Call here f1 function 
This is b:f2 function

Friday, November 30, 2012

how to call one class method from another in php

<?php
class a{ public function f1(){
echo 
'this is a:f1 function';  
}
 
}

class 
b{

function 
f2(){

  a::f1(); // claa here method of another class in php
  echo '<br> This is b:f2 function';
}

}
$ob= new b();

$ob->f2(); 

?>

OutPut:
this is a:f1 function
This is b:f2 function

Thursday, November 29, 2012

group_concat in mysql example

group_concat in mysql example

CITY_ID CITY_NAME STATE_NAME
1 Bhopal MP
2 Indore MP
3 Delhi DELHI
4 Allahabad UP


SELECT group_concat(concat(`city_id`,'@@', `city_name`,'@@', `state_name`),'###') as city FROM `city`


Result

1@@Bhopal@@MP###,2@@Indore@@MP###,3@@Delhi@@DELHI###,4@@Allahabad@@UP###

Wednesday, November 28, 2012

date between two date in php

<?php
 
// check datebetween two dates 
function chkbetweendate($chkdate='',$startdate='',$enddate=''){ 

$chkdate=strtotime($chkdate);
$startdate=strtotime($startdate);
$enddate=strtotime($enddate); 

if(
$startdate <= $chkdate && $chkdate <= $enddate){
return 
true;
}else {
return 
false;
}
}
 
 
 
 
// call function here 
 
 
if(chkbetweendate('2012-10-10','2012-10-5','2012-10-15')){
 echo 
"2012-10-10 between date";
 } else {
 echo 
"2012-10-10 not in between date";
 }

Tuesday, November 6, 2012

Create Query for all table in mysql


1. create query for change all tables to innodb ENGINE in mysql


SELECT CONCAT('ALTER TABLE ', table_name, ' ENGINE=InnoDB;') as ExecuteTheseSQLCommands
FROM information_schema.tables WHERE table_schema = 'database_name'
ORDER BY table_name DESC;

2. create query for  TRUNCATE TABLE  all database table


SELECT CONCAT('TRUNCATE TABLE ', table_name, ';')
FROM INFORMATION_SCHEMA.tables
WHERE table_schema = 'database_name'

export in mysql

1. export in mysql in txt file 

SELECT * FROM  MyTable INTO OUTFILE  'C:\\FileName.txt' 

2.  export in mysql in csv file 

SELECT * FROM table1  INTO OUTFILE 'c:///mytable.csv' FIELDS ESCAPED BY '""' TERMINATED 
BY ','  ENCLOSED BY '"' LINES TERMINATED BY '\r\n' 

3. . export in mysql in excel file


Monday, November 5, 2012

php multidimensional array to single dimension array

<?php 

php convert multidimensional array to single dimension array

convert multidimensional array to single array php



function multidimensional_array_to_single_dimension_array($array) { 
   if (!
$array) return false;
   
$flat = array();
   
$iterator  = new RecursiveIteratorIterator(new RecursiveArrayIterator($array));
  
   foreach (
$iterator as $value$singhal[] = $value;
   return 
$singhal;
}
$arr=array(1,2,array(4,5),6,array(7,8,array(9,10,11,array(12,13,14))));

 
 
print_r(multidimensional_array_to_single_dimension_array($arr)); ?>



OUTPUT:

Array ( [0] => 1 [1] => 2 [2] => 4 [3] => 5 [4] => 6 [5] => 7 [6] => 8 [7] => 9 [8] => 10 [9] => 11 [10] => 12 [11] => 13 [12] => 14 )


Saturday, November 3, 2012

Regular Expression

Regular Expression in JavaScript




Regular Expression in php





Regular Expression in MySql 


Wednesday, October 31, 2012

transaction in mysql php

<?php 
MYISAM Not Support Transaction 

/*
CREATE TABLE IF NOT EXISTS `table1` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(250) NOT NULL,
  `address` varchar(250) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
*/

$host 'localhost'
$user 'rajeev'
$password 'mypass';
$db 'demo'

$con mysql_connect($host$user$password);

mysql_select_db$db);

mysql_query("SET AUTOCOMMIT=0");
mysql_query("START TRANSACTION");  

 
$query "INSERT INTO table1 (name,address) values ('name','bhopal')";
 
$result mysql_query($query);
  

if($result){
 
mysql_query("COMMIT");
 }  else {
 
mysql_query("ROLLBACK");
 }
 
 
mysql_close();

?>

Saturday, October 27, 2012

Create New User In Mysql with permission


create new user in mysql database
set user permissions mysql
delete user permissions in mysql



rajeev=User Name
mypass= Password
demo= database name

  // create user
CREATE USER 'rajeev'@'localhost' IDENTIFIED BY  'mypass' ;

   // set permission  in demo database 
GRANT SELECT, INSERT, DELETE ON  demo.* TO rajeev@'localhost' IDENTIFIED BY 'mypass';

 // set all permission in demo database
GRANT ALL ON demo.* to 'rajeev'@'localhost';

 // remove access permission from demo database
REVOKE select, UPDATE, DELETE ON demo.*  FROM 'rajeev'@'localhost';

 // remove all permission 
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'rajeev'@'localhost';

 // select user detail  from database 
select * from mysql.user where User='rajeev';


Friday, October 26, 2012

Email Validation In PHP

Email address Validation in PHP   

<form> Email Address: <input type='text' name='email'> <input type='submit' value='Submit'> </form>
 
<?php
 $email
=$_REQUEST['email']; 


 
$expression "^[a-z0-9_\+-]+(\.[a-z0-9_\+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,4})$"


 if (
eregi($expression$email)) {
 echo 
'Valid Email'


 } else { 


 echo 
'Invalid Email';
 }
 
?>

Tuesday, October 2, 2012

user already exits

This Code Is use for User name Already Exits or email id already exits 

here this function call using Ajax Method 

<?php 

function ckhuserid($udetail){

$arr=explode("!@@@!",$udetail); 

if(
$arr[1]=='edit'){

$val=executescalar("user","id","uname='".$arr[0]."' and id<>'".$arr[2]."' ""","false","str"); 

} else { 


$val=executescalar("user","id","uname='".$arr[0]."'""","false","str");
 }
if(
$val!=''){ // alresdy exist 
 
echo "yes";
}

?> 


// JavaScript Code

<script>
            
function ckhuserid(x,cas,id){ // x=this; cas= case=registration or edit profile , id=user id on edit time 
uname=$(x).val();
str=uname;
if(cas=='edit'){
str=uname+"!@@@!edit!@@@!"+id;
}
$.ajax({
  type: 'POST',
  url: "admin/Ajax/functions.php?f=ckhuserid&p="+str,
  data: {},
  success: function(data12){ 
 // alert(data12);
  if(data12=='yes'){
      alert("user name already exist"); $(x).focus(); return false ;
  }   
   
  }});
    return true ;
}
</script> 



// calling method 

<input type="text" onblur="return ckhuserid(this,0,0)"  /> // add time

<input type="text" onblur="return ckhuserid(this,'edit',id)"  /> // edit  time

Saturday, September 22, 2012

Email Validation For Group Mail

Email Address:

Example: Email1, Email2, Email3 etc




function ckhmailaddress(){

var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
var allemail = $('#txtemail').val() ;
var email = allemail.split(",");
for(i=0 ; i< email.length ; i++){
if(emailPattern.test(email[i])==false){
   alert('please Enter Valid Email Id');
    document.getElementById('txtemail').focus();
    return false ;
   }
}

return true ;
 }


Sunday, August 26, 2012

contact us page


For Me  

<?php  /***************** PHP Code **********************/ 


require_once('config/bootstrap.php'); 

if(isset(
$_POST) && ($_REQUEST["mode"]=='send')){

$name strip($_POST['txtname']); 
$email strip($_POST['txtemail']); 
$ph strip($_POST['txtphone']);
$msg strip($_POST['txtcomment']);

$headers =  "From: ".$email."\r\n"
$headers .= 'MIME-Version: 1.0' "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
$headers .= "\r\nX-Mailer: PHP/" phpversion();
$subject "contact us: nethomes.com";
$message "Name: " $name ."<br> Phone No: " $ph"<br/>Email Id:".$email "<br/>Message Details : " $msg  ;

$to =  "bit7bpl@gmail.com"// "arteriors51@yahoo.com"; 

if(mail($to$subject $message ,$headers)){ 
redirect("projectprofile.php"," Thank you for sending your valueable feedback/ query. We will get back to you as soon as possible. ");
 }
else {
redirect("projectprofile.php"," Please Try Again  ");
 }


/****************   End Mail *************/ ?>

/***************** JavaScript Validation ****************************/
<script>

function formvalidation(){ 


if(document.getElementById('txtname').value==''){
alert('Please enter name');document.getElementById('txtname').focus(); return false ;  }
if(document.getElementById('txtemail').value==''){
alert('Please enter Email id');document.getElementById('txtemail').focus(); return false ;  }
if(document.getElementById('txtemail').value!=''){
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
email = document.getElementById('txtemail').value ;
if(emailPattern.test(email)==false){
alert('please Enter Valid Email Id');
document.getElementById('txtemail').focus();
return false ;
 }
    }    
if(document.getElementById('txtphone').value==''){
alert('Please enter Phone no');document.getElementById('txtphone').focus(); return false ;  }
if(document.getElementById('txtcomment').value==''){
alert('Please enter message');document.getElementById('txtcomment').focus(); return false ;  }
}    
</script>


/******************* HTML Code  **********************************/

<form  action="projectprofile.php?mode=send" method="post" enctype="multipart/form-data" name="form1" id="form1">
 <table width="364" height="237" align="left" cellpadding="0" cellspacing="2">
  

 <tr> 
  <td width="29%" align="left"><p>Name </p></td>
  <td width="3%"><p>:<span class="preeti">:</span></p></td>
  <td width="68%"><label>
  <input name="txtname" type="text" id="txtname"  />
   </label></td>
   </tr>
   <tr>
  <td align="left"><p class="white">Email ID </p></td>
   <td><p>:<span class="preeti">:</span></p></td>
   <td><label>
    <input name="txtemail" type="text" id="txtemail" />
       </label></td>
    </tr>
    <tr>
 <td align="left"><p><span class="white">Tel. No. </span></p></td>
   <td width="3%"><p>:<span class="preeti">:</span></p></td>
  <td><input name="txtphone" type="text" id="txtphone"  maxlength="12" onkeypress="isnumberkey(event);" /></td>
   </tr>
  <tr>
 <td align="left"><p><span class="white">your message
 </span></p></td>
   <td><p>:<span class="preeti">:</span></p></td>
  <td><textarea name="txtcomment" cols="28" rows="4" id="txtcomment" ></textarea></td>
  </tr>
    <tr>
  <td height="26">&nbsp;</td>
    <td>&nbsp;</td>
 <td><input name="Send" type="submit" value="   Send    " onclick="return formvalidation();" class="butt"></td>
  </tr>
  </table>
  </form>

Saturday, August 25, 2012

add data without html editor

str_replace('&nbsp;',' ',strip_tags($_POST["txtcomment"]))

Friday, August 24, 2012

add more input box in html




/**************** HTML Code **************************/
<tr>
<td width="30%" align="right"  valign="top"> <label class="mylbl">  Contact person  &nbsp;</label></td>
<td width="50%"  valign="top">
<table id="addmorecontact">
<tr>
<td><label class="mylbl">  Name &nbsp;</label> </td>
<td><label class="mylbl"> Designation &nbsp;</label> </td>
<!-- <td>  </td>-->
</tr>
<tr id="inputbox0">
    <td><input type="text" name="txtname[]" id="txtname0" style="width:200px" class="box " /> </td>
<td> <input type="text" name="txtdesig[]" id="txtdesig0" style="width:185px" class="box " /></td>
<td id="addmorebtn0">  <input type="button" value="ADD MORE" class="com_btn" onclick="return addmorecontact();"  /> </td>
</tr>
</table>
</td>
<td width="25%"  valign="bottom" align="left" id=" "></td>
</tr>

<input type="hidden" name="hidaddmorecp" id="hidaddmorecp" value="0"  />






/*************************** JAVASCRIPT Code *****************/
function addmorecontact(){
i=1; id=$('#hidaddmorecp').val();
if($('#txtname'+id).val()==''){ alert('Please enter name'); $('#txtname'+id).focus(); return false ; }
if($('#txtdesig'+id).val()==''){ alert('Please enter designation'); $('#txtdesig'+id).focus(); return false ; }
i=add(i,id);
$('#addmorebtn'+id).html("<input type='button' value='REMOVE' class='com_btn' onclick='return removemorecontact(\"inputbox"+id+"\");'  />");
$('#addmorecontact').append("<tr id='inputbox"+i+"'><td><input type='text' name='txtname[]' id='txtname"+i+"' style='width:200px' class='box ' /> </td><td> <input type='text' name='txtdesig[]' id='txtdesig"+i+"' style='width:185px' class='box ' /></td> <td id='addmorebtn"+i+"'>  <input type='button' value='ADD MORE' class='com_btn' onclick='return addmorecontact();'  /> </td></tr>");
 $('#hidaddmorecp').val(i)
}
function removemorecontact(x){
$('#'+x).remove();
}
function add(x,y){
z=parseInt(x)+parseInt(y);
return z;
}


Friday, August 17, 2012

how to upload image into database using php


how to upload file in database in php

how to upload image into database using php

step 1

1. create database demo


CREATE TABLE IF NOT EXISTS `table1` (
  `id` int(11) NOT NULL auto_increment,
  `file` longblob NOT NULL COMMENT 'file in binary',
  `type` varchar(250) NOT NULL,
  `name` varchar(250) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


2. create two file 


demo.php

photo.php


demo.php

<?php 

$con
=mysql_connect('localhost','root','');
mysql_select_db('demo',$con);

//print_r($_FILES);
if(isset($_REQUEST['sub'])){
 
$tpy=$_FILES['txtfile']['type'];
  
$name=$_FILES['txtfile']['name'];
   
$c=file_get_contents($_FILES['txtfile']["tmp_name"]);
mysql_query("insert into table1(file,type,name) values('".addslashes($c)."', '".$tpy."', '".$name."')");
}
$arr=mysql_query("select * from table1");
while(
$r=mysql_fetch_array($arr)){
// echo "<img src='photo.php?id=".$r[0]."'  />";
 
echo "<a href='photo.php?id=".$r[0]."'>Download here </a>";
 }
?>

<form action="" enctype="multipart/form-data" method="post">
<input type="file" name="txtfile"  />
<input type="submit" name="sub" value="submit"  />
</form> 

photo.php

<?php 

$con
=mysql_connect('localhost','root','');
mysql_select_db('demo',$con);

$arr=mysql_query("select * from table1 where id= '".$_REQUEST['id']."' ");
while(
$r=mysql_fetch_array($arr)){
header("Content-Disposition: attachment;filename=".$r['name']."");
$ty=$r[2];
header("Content-type:".$ty."");
echo 
$r[1];



}
?>

Monday, August 6, 2012

dd-mm-yyyy in javascript

date format in javascript dd mm yyyy



Chang date format in JavaScript

function datef(x){
var arr = new Array();
arr=["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
arr2=x.split('-');
i=parseInt(arr2[1],10);
d=arr2[2]+"-"+arr[i]+"-"+arr2[0];
return d;
}

Friday, July 27, 2012

how to get past date in php

<?php // get past 15 days date  in php

$d1=date('Y-m-d'strtotime('-15 days')); 



date('Y-m-d'strtotime('-15 months')); 

//$d1=date('Y-m-d'strtotime('-20 year')); 


// next 15 days date in php

$d1=date('Y-m-d', strtotime('15 days'));


 $date = "2012-10-10";
$newdate = strtotime ( '-10 days' , strtotime ( $date ) ) ;
$newdate = date ( 'Y-m-d' , $newdate );

echo $newdate;

?>

Wednesday, July 25, 2012

how to execute php code in html

1. create   .htaccess  file and write code 

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html




this file in htdocs or WWW folder and create your html page and write php code 


in html file


Example :


myfolder
   .htaccess
   demo.html


in demo.html


<?php echo "My Name is rajeev "; ?>

Tuesday, July 24, 2012

unicode of rupees symbol


Unicode of rupee symbol  

&#x20b9; 

Monday, July 23, 2012

get all value of drop down list





<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
function getalloption(){
arr=$('#ddlname option')

for(i=0; i< arr.length; i++){
alert($(arr[i]).val());
alert($(arr[i]).text());

 }



}

</script>
<select name="ddlnane" id="ddlname" >
<option value="1"> One </option>
<option value="2"> Two </option>
<option value="3"> Three </option>
<option value="4"> Fore </option>
<option value="5"> Five </option>
</select>
<input type="button" onclick="getalloption();" value="getOption"  />

Thursday, July 19, 2012

url encryption and decryption in php

<?php
$ide=5 ;
$id= base64_encode($ide);  // convert to NQ==

echo base64_decode($id); ?> // output  5

Thursday, July 12, 2012

remove leading zeros in javascript

Mobile No(beginning With Zero ) :


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
function removeZero(s) {
  while (s.substr(0,1) == '0' && s.length>1) { s = s.substr(1,500); }
  return s;
}

function removeFirstZero(){
alert("orisinal value : "+$('#txtmobile').val());
var mob=removeZero($('#txtmobile').val());
alert("After remove Zero :  "+mob);

$('#txtmobile').focus();
return false ;

}
</script>
 Mobile No(beginning  With Zero ) :
 <input type="text" name="txtmobile" id="txtmobile"   style="width:300px"  class="required"/>
<input type="submit" name="btnsubmite" class="myButton" onclick="return removeFirstZero();" id="btnsubmite" value=" Get Value "/>






Tuesday, July 10, 2012

how to get all options of a select using javascript




<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<script>
function getalllist(){
var len = document.addform.ddllist.length;  // alert(len);
var txt ='' ; // alert(len);
var values='';
arr=$("#ddllist option");
for(var i = 0; i < len ; i++) {
values+=document.addform.ddllist.options[i].value +"------" ; // form name  select box name
txt+=document.addform.ddllist.options[i].text +"------" ;
}
alert("All Values : "+ values);

alert("All Text Values : "+ txt);
}
</script>


<form   name="addform" method="post" action="#" id="addform">
<select multiple="multiple" name="ddllist" id="ddllist" >
<option value="php">PHP </option>
<option value="js">JAVASCRIPT </option>
<option value="css">CSS </option>
<option value="sql">MYSQL </option>

</select>

<input type="button" name="getvalue" value="ALL VALUE" onClick="getalllist();" />


</form>

Friday, July 6, 2012

jquery check only one checkbox


 

how to check only one checkbox in gridview
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>


<script language="javascript">
function checkOnly(x)
  {
  $('.checkbox').attr("checked", false);
    $(x).attr("checked", true);
  }      
</script>
</head>

<body>
<form >
<input type="checkbox" name="cb1" value="1" class="checkbox" onclick="checkOnly(this)">
<input type="checkbox" name="cb2" value="1" class="checkbox"  onclick="checkOnly(this)">
<input type="checkbox" name="cb3" value="1" class="checkbox"  onclick="checkOnly(this)">
</form>





how to prevent enter key submitting form


Name :
Emai :

<script>

 $(document).keypress(function(e) {
            if (e.which == 13) {
            var $targ = $(e.target);

            if (!$targ.is("textarea") && !$targ.is(":button,:submit")) {
                var focusNext = false;
                $(this).find(":input:visible:not([disabled],[readonly]), a").each(function() {
                    if (this === e.target) {
                        focusNext = true;
                    }
                    else if (focusNext) {
                        $(this).focus();
                        return false;
                    }
                });

                return false;
            }
        }
    });
 </script>

Thursday, July 5, 2012

php string to javascript array




<?php  $str="RAJEEV~@~DHAR~@~DWIVEDI";   ?>
<script>
function getarray(x){
var str="<?php echo $str ; ?> ";
var arr=str.split('~@~');

alert(arr[0]); alert(arr[1]); alert(arr[2]);
}
</script>
<input type="button" value="getarray" name="GET ARRAY" onclick="getarray();"  />

Wednesday, July 4, 2012

How to php convert associative array to indexed array in PHP

get index  of array in php
<?php
$arr
=array('index1' =>'value1' "index2" =>'value2' "index3"=>'value3'); 


$ar=array_values($arr); // convert to indexing  array 


$key=array_keys($arr); // get index name 


for($i=0$icount($ar) ; $i++){
echo 
$key[$i]."=".$ar[$i]."<br> ";
}
 
?>

output

index1=value1
index2=value2
index3=value3

Sunday, July 1, 2012

shortcut key for internet

1. how to clear all history bookmark from firefox

 Press Ctrl+Shift+Del  

Saturday, June 30, 2012

how to add value in array in php

How to Add more value in php array 
<?php


array_push
(array name ,value1,value2,value3,....);


$ss=array(); // array declaration

array_push($ss,'val1');  // array name , value
?>

how to add 30 days to a date in javascript




<script>
function today(x){
y=parseInt(x);
var d1=new Date((new Date()).getTime() + y*24*60*60*1000) ;
var rr = d1.toString('yyyy-MM-dd');
a=rr.split(' ');
d=a[2]+'-'+a[1]+'-'+a[3];
//return d ;
alert(d);
}
</script>

<input type="button" onclick="return today(0);" value="Today date"  />

<input type="button" onclick="return today(25);" value="NEXT 25 Days Date"  />


date picker in jquery  



$( ".txtdate" ).datepicker({
changeMonth: true,
changeYear: true
});
$( ".txtdate" ).datepicker( "option", "dateFormat", "dd-M-yy");
        $( ".txtdate" ).val(today('0'));




1. download necessary file from jquery 
2. call txtdate class in input box

Wednesday, June 27, 2012

database connection in cakephp

database connection in cakephp

1. Open app / config / database.php 


<?php
public $default 
= array(
        
'datasource' => 'Database/Mysql',
        
'persistent' => false,
        
'host' => 'localhost',
        
'login' => 'user',
        
'password' => '',  // here password
        
'database' => 'cakephp'// its my database name
        
'prefix' => '',
        
//'encoding' => 'utf8',
    
); ?>



Monday, June 25, 2012

How To Use HTML Editor online

how to use html editor

1. download html editor from http://nicedit.com/download.php

2.  copy and paste in a folder ,  Example: A   folder name

3. now create new folder within folder , Example : B    Folder name

4.   two file  nicEdit.js   and   nicEditorIcons.gif   (get from download)  paste on A folder

5.create demo.html file , on folder

6.  demo.html

<script type="text/javascript" src="../nicEdit.js"></script>
<script type="text/javascript">
// add text editor 
bkLib.onDomLoaded(function(){
var myEditor = new nicEditor({fullPanel : true }).panelInstance('mytxtarea');
  myEditor.addEvent('add', function() {   });
});
</script>


<h4>Textarea</h4>
<textarea name="area1" cols="40" id="mytxtarea" name="mytxtarea">     </textarea>


7. how to get content from nicedit 
function getcontain(){
var nicE = new nicEditors.findEditor('mytxtarea'); // for use validation time
value = nicE.getContent();
alert(value);
}

8. how to set content from nicedit
function setcontain(){
nicEditors.findEditor('mytxtarea').setContent(' <strong>Some HTML</strong> here');  // for use update time
}





Saturday, June 23, 2012

php warning mail function.mail failed to connect to mailserver at localhost port 25

php warning mail function.mail failed to connect to mailserver at localhost port 25

php warning mail function.mail failed to connect to mailserver at localhost port 25


ini_set('SMTP' , 'Server address')



how to find server address :


open run and type :  ping www.google.in -t   // www.google.in your site address
example :

ini_set('SMTP' , '74.125.236.191')

how to create cookies in javascript



how to set cookie in javascript
how to get cookie value in javascript


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>

function setCookie(){
document.cookie='mycookie';
 alert('cookies Successfully set');
}

function getCookie(){
 var cv = document.cookie.split( ';');
 alert(cv[0]);  // get cookies value
}

</script>

 <input type="button" value="setCookie" onclick="setCookie();"  name="setcookie" />

 <input type="button" name="getcookie" value="getcookie" onclick="getCookie();"  />

Friday, June 22, 2012

select only image file validation in javascript




<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
function imageOnly(){
var file = $('#txtfile').val();
ext = file.substr(file.lastIndexOf('.')+1);
alert(ext);
if(ext=='jpg' || ext=='png' || ext=='gif' || ext=='bmp' || ext=='tif' ){}else { alert('Please select only Image'); $('#txtfile').focus(); return false ;}
}
</script>

<input type="file" name="txtfie" id="txtfile"  />  <input type="button" value="Upload File" onclick="return imageOnly();"  />

Wednesday, June 20, 2012

case when then in mysql


gender = column name

table = table name



SELECT * ,

CASE   gender when 'm' then 'male'
              when 'f' then 'Female'   else gender
END as ty



FROM  Table









SELECT * ,

CASE  when   id > 5   then 'male'
              when   id < 5   then 'Female'   else gender
 END as ty



FROM  Table




Thursday, June 14, 2012

how to auto close alert box javascript

how to auto close alert box javascript
how to auto close alert box javascript

I am also searching this code , if you found please comment code here

thanks