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 

date format in javascript dd mmm yyyy

 date format in javascript dd mmm yyyy  


<script type="text/javascript">
function todayDate(){
var d1=new Date();
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" name=" Check " onclick="todayDate()" value="click"  />

Friday, June 8, 2012

number to word conversion in javascript


how to add value one select box to another select box


Select Branch :







<script>
function addSrcToDestListM() {
 ddlbranch = window.document.formmanage.ddlbranch;  // form name.slelect id
ddlbranch1 = window.document.formmanage.ddlbranch1;
var len = ddlbranch.length;  // alert(len);
for(var i = 0; i < ddlbranch1.length; i++) {
if ((ddlbranch1.options[i] != null) && (ddlbranch1.options[i].selected)) {
var found = false;
for(var count = 0; count < len; count++) {
if (ddlbranch.options[count] != null) {
if (ddlbranch1.options[i].text == ddlbranch.options[count].text) {
found = true;
break;
      }
   }
}

if (found != true) {


ddlbranch.options[len] = new Option(ddlbranch1.options[i].text,ddlbranch1.options[i].value);
len++;


         }
      }
   }
var ddlbranchx  = window.document.formmanage.ddlbranch;
var lenx = ddlbranchx.options.length;
if(lenx!=1){
for(var ix = (lenx-1); ix >= 0; ix--) {
if ((ddlbranchx.options[ix] != null) && (ddlbranchx.options[ix].text== "Any")) {
ddlbranchx.options[ix] = null;
}
}}
}


function deleteFromDestListM() {
var ddlbranch  = window.document.formmanage.ddlbranch;
var len = ddlbranch.options.length;
for(var i = (len-1); i >= 0; i--) {
if ((ddlbranch.options[i] != null) && (ddlbranch.options[i].selected == true)) {
ddlbranch.options[i] = null;
      }
   }
}





</script>




<form id="form-manage" name="formmanage" method="post" action="pages/manage_inspection_officer.php">
<table width="100%" cellpadding="5" cellspacing="5">




<tr >
<td align="right" valign="top"><span class="text"> Select Branch :</span></td>
<td align="left" colspan="2" >
<table width="80%" cellspacing="0" >
<tr>
<td align="left">
   <select name="ddlbranch1" id="ddlbranch1" size="10" multiple="multiple" style="width:150px; z-index:1000000000" class="combo" >
     <option value="0">--- Select branch ---</option>
<option value="1">---  branch 1---</option>
<option value="2">---  branch 2---</option>
<option value="3">---  branch 3---</option>
<option value="4">---  branch 4---</option>
   </select>
   </td>
   <td align="left">
   <input type="button" name="Add" value=" Add " id="add"  class="myButton" style="vertical-align:top;width:110px;" onclick="javascript:addSrcToDestListM();" /><br /><br />
   <input type="button" name="Remove" value="Remove" id="remove" class="myButton" style="vertical-align:top; width:110px;" onclick="javascript:deleteFromDestListM();" /><br /><br />
   </td>
<td align="left">
<select name="ddlbranch" id="ddlbranch" size="10"  style="width:150px; z-index:1000000000" class="combo" >
   
   </select>  
 </td>


 </table>  
</td>
</tr>







</table>


</form>














Thursday, June 7, 2012

on click null inputbox using javascript



<input type="text" name="txtcity" id="txtcity" style="float:left; width:70px ; margin-right:5px;color: rgb(204, 204, 204); " value="City" onFocus="if (this.value == 'City'){this.value='';this.style.color='#000000';}" onBlur="if (this.value == ''){this.value='City';this.style.color='#cccccc';}"   />

Sunday, June 3, 2012

mp govt jobs in bhopal

 are you searching government job in mp  . there are two place where you find government job in mp .

1.  http://www.mpinfo.org/

2.  http://www.vyapam.nic.in/e_default.htm


There are many site who is provide the information about  government job in India  such as

http://www.freejobalert.com/

http://jobs.freshersworld.com/jobs


and other

Saturday, June 2, 2012

how to get top 3 records in sql


how to get top 3 records in sql  , or   how to get top 3 (RECENT ) record from mysql

query :

SELECT  * FROM TABL_NAME ORDER BY ID DESC LIMIT 0,3 



how to update multiple rows in mysql with one query with different values



UPDATE `tbname` SET `column_name` = CASE  `id`
WHEN '1' THEN '1'
WHEN '2' THEN '2'
WHEN '3' THEN '3'

END